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

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

From
JSJeff Sipek <jeffpc@josefsipek.net>
Date
Mar 14, 2012, 14:21 UTC
Message-ID
<20120314142144.GB12588@poseidon.cudanet.local>
In-Reply-To
<87399bpaq9.fsf@opera.com>
On Wed, Mar 14, 2012 at 02:34:38PM +0100, Per Cederqvist wrote:
> 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.

I just ran into this yesterday. I stupidly changed the caller of sha1 to pass in - for the filename. That worked for me since I ended up using the sha1sum implementations; openssl is not happy about that. So, your patch looks good.

Now, I should actually figure out how to get the git repo out there again.
Thanks,
Jeff.
Show 69 quoted lines
> 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
> 
-- 
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
		- Albert Einstein
Previous: Per CederqvistNext: Andreas Schwab
Message 2 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.