Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
[PATCH] Add '-z' to merge-tree.c
author
Junio C Hamano
<junkio@cox.net>
Sat, 16 Apr 2005 02:20:42 +0000
(19:20 -0700)
committer
Linus Torvalds
<torvalds@ppc970.osdl.org>
Sat, 16 Apr 2005 02:20:42 +0000
(19:20 -0700)
This adds '-z' to merge-tree and changes its default line termination to
LF to make it consistent with your other recent changes.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
merge-tree.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
6cbd72f
)
diff --git
a/merge-tree.c
b/merge-tree.c
index 00ae4e8d3208e09f2cf7a38202a126f728cadb48..ef9a54d4106771b82b13eabe3203dc59e72e1c9d 100644
(file)
--- a/
merge-tree.c
+++ b/
merge-tree.c
@@
-1,5
+1,7
@@
#include "cache.h"
#include "cache.h"
+static int line_termination = '\n';
+
struct tree_entry {
unsigned mode;
unsigned char *sha1;
struct tree_entry {
unsigned mode;
unsigned char *sha1;
@@
-35,7
+37,8
@@
static struct tree_entry *read_tree(unsigned char *sha1)
static void show(const struct tree_entry *a, const char *path)
{
static void show(const struct tree_entry *a, const char *path)
{
- printf("select %o %s %s%c", a->mode, sha1_to_hex(a->sha1), path, 0);
+ printf("select %o %s %s%c", a->mode, sha1_to_hex(a->sha1), path,
+ line_termination);
}
static void merge(const struct tree_entry *a, const struct tree_entry *b, const struct tree_entry *c, const char *path)
}
static void merge(const struct tree_entry *a, const struct tree_entry *b, const struct tree_entry *c, const char *path)
@@
-46,7
+49,7
@@
static void merge(const struct tree_entry *a, const struct tree_entry *b, const
strcpy(hex_c, sha1_to_hex(c->sha1));
printf("merge %o->%o,%o %s->%s,%s %s%c",
a->mode, b->mode, c->mode,
strcpy(hex_c, sha1_to_hex(c->sha1));
printf("merge %o->%o,%o %s->%s,%s %s%c",
a->mode, b->mode, c->mode,
- hex_a, hex_b, hex_c, path,
0
);
+ hex_a, hex_b, hex_c, path,
line_termination
);
}
static int same(const struct tree_entry *a, const struct tree_entry *b)
}
static int same(const struct tree_entry *a, const struct tree_entry *b)
@@
-114,15
+117,29
@@
static void merge_tree(struct tree_entry *src, struct tree_entry *dst1, struct t
}
}
}
}
+static const char *merge_tree_usage =
+ "merge-tree [-z] <src> <dst1> <dst2>";
+
int main(int argc, char **argv)
{
unsigned char src[20], dst1[20], dst2[20];
int main(int argc, char **argv)
{
unsigned char src[20], dst1[20], dst2[20];
+ while ((1 < argc) && argv[1][0] == '-') {
+ switch (argv[1][1]) {
+ case 'z':
+ line_termination = 0;
+ break;
+ default:
+ usage(merge_tree_usage);
+ }
+ argc--; argv++;
+ }
+
if (argc != 4 ||
get_sha1_hex(argv[1], src) ||
get_sha1_hex(argv[2], dst1) ||
get_sha1_hex(argv[3], dst2))
if (argc != 4 ||
get_sha1_hex(argv[1], src) ||
get_sha1_hex(argv[2], dst1) ||
get_sha1_hex(argv[3], dst2))
- usage(
"merge-tree <src> <dst1> <dst2>"
);
+ usage(
merge_tree_usage
);
merge_tree(read_tree(src), read_tree(dst1), read_tree(dst2));
return 0;
}
merge_tree(read_tree(src), read_tree(dst1), read_tree(dst2));
return 0;
}