git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add '-z' to merge-tree.c

From
Junio C Hamano <junkio@cox.net>
Date
Apr 16, 2005, 01:17 UTC
Message-ID
<7vekdbfrju.fsf@assigned-by-dhcp.cox.net>
Linus,
    this adds '-z' to merge-tree and changes its default line
termination to LF to make it consistent with your other recent
changes.
The patch is against
    commit 028c5948257e763b3deb391e567b624eb7975ec2
    tree   6b866e10b16183e630db8449c64899f6810d4270
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 merge-tree.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

--- ,,linus/merge-tree.c 2005-04-15 18:09:29.000000000 -0700 +++ ./merge-tree.c 2005-04-15 17:55:42.000000000 -0700

@@ -1,5 +1,7 @@
 #include "cache.h"
 
+static int line_termination = '\n';
+
 struct tree_entry {
 	unsigned mode;
 	unsigned char *sha1;
@@ -35,7 +37,8 @@ static struct tree_entry *read_tree(unsi
 
 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)
@@ -46,7 +49,7 @@ static void merge(const struct tree_entr
 	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)
@@ -114,15 +117,29 @@ static void merge_tree(struct tree_entry
 	}
 }
 
+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];
 
+	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))
-		usage("merge-tree <src> <dst1> <dst2>");
+		usage(merge_tree_usage);
 	merge_tree(read_tree(src), read_tree(dst1), read_tree(dst2));
 	return 0;
 }
Message 1 of 1 in “Add '-z' to merge-tree.c”
  1. Add '-z' to merge-tree.cJunio C Hamano, Apr 16, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.