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

[GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.

From
Per Cederqvist <cederp@opera.com>
Date
Mar 14, 2012, 13:34 UTC
Message-ID
<87399bpaq9.fsf@opera.com>

Fix the compatibility function sha1 so that it reads from stdin (and not a file with a zero-length file name) when no argument is supplied.

Signed-off-by: Per Cederqvist <cederp@opera.com>
---
 os.Darwin |    7 ++++++-
 os.Linux  |    7 ++++++-
 os.SunOS  |    7 ++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)
Note: I have tested both versions of the sha1 function, but only on
Linux as I don't have access to a Mac.
    /ceder
diff --git a/os.Darwin b/os.Darwin
index 470f5fb..acf6b68 100644
--- a/os.Darwin
+++ b/os.Darwin
@@ -27,7 +27,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
+	if [ $# = 1 ]
+	then
+		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
+	else
+		openssl dgst -sha1 | sed 's,$,  -,'
+	fi
 }
 
 # usage: cp_a <src> <dst>
diff --git a/os.Linux b/os.Linux
index 30b9cb0..aaebf88 100644
--- a/os.Linux
+++ b/os.Linux
@@ -30,7 +30,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	sha1sum "$1"
+	if [ $# = 1 ]
+	then
+		sha1sum "$1"
+	else
+		sha1sum
+	fi
 }
 
 # usage: cp_a <src> <dst>
diff --git a/os.SunOS b/os.SunOS
index 30b9cb0..aaebf88 100644
--- a/os.SunOS
+++ b/os.SunOS
@@ -30,7 +30,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	sha1sum "$1"
+	if [ $# = 1 ]
+	then
+		sha1sum "$1"
+	else
+		sha1sum
+	fi
 }
 
 # usage: cp_a <src> <dst>
-- 
1.7.9
Next: Jeff Sipek
Message 1 of 6 in “Fix fatal "guilt graph" error in sha1sum invocation.”
  1. Per CederqvistMar 14, 2012
  2. Jeff SipekMar 14, 2012
  3. Andreas SchwabMar 14, 2012
  4. Per CederqvistMar 15, 2012
  5. Andreas SchwabMar 15, 2012
  6. John SzakmeisterMar 15, 2012

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.