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

[PATCH] hash-object: don't rely on order of --stdin, -w arguments

From
Gerrit Pape <pape@smarden.org>
Date
Feb 13, 2008, 19:03 UTC
Message-ID
<20080213190338.7393.qmail@d70c5cbe18d4bd.315fe32.mid.smarden.org>

Fix 'git hash-object --stdin -w' to actually write the object, just as 'git hash-object -w --stdin' does.

Reported by Josh Triplett through
 http://bugs.debian.org/464432
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 hash-object.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hash-object.c b/hash-object.c
index 0a58f3f..ff60f0f 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -41,6 +41,7 @@ int main(int argc, char **argv)
 	const char *prefix = NULL;
 	int prefix_length = -1;
 	int no_more_flags = 0;
+	int hashstdin = 0;
 
 	git_config(git_default_config);
 
@@ -64,9 +65,8 @@ int main(int argc, char **argv)
 			}
 			else if (!strcmp(argv[i], "--help"))
 				usage(hash_object_usage);
-			else if (!strcmp(argv[i], "--stdin")) {
-				hash_stdin(type, write_object);
-			}
+			else if (!strcmp(argv[i], "--stdin"))
+				hashstdin = 1;
 			else
 				usage(hash_object_usage);
 		}
@@ -79,5 +79,7 @@ int main(int argc, char **argv)
 			no_more_flags = 1;
 		}
 	}
+	if (hashstdin)
+		hash_stdin(type, write_object);
 	return 0;
 }
-- 
1.5.4.1
Next: Junio C Hamano
Message 1 of 7 in “hash-object: don't rely on order of --stdin, -w arguments”
  1. hash-object: don't rely on order of --stdin, -w argumentsGerrit Pape, Feb 13, 2008
  2. Junio C HamanoFeb 13, 2008
  3. hash-object: don't rely on order of --stdin, -w argumentsGerrit Pape, Feb 13, 2008
  4. Junio C HamanoFeb 13, 2008
  5. hash-object: cleanup handling of command line optionsGerrit Pape, Feb 14, 2008
  6. Junio C HamanoFeb 15, 2008
  7. hash-object: cleanup handling of command line optionsGerrit Pape, Feb 21, 2008

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.