Re: Bug: pull --rebase with é in name

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: Bug: pull --rebase with é in name

From: Thomas Rast <hidden>
Date: 2016-06-15 22:53:13

Jeff King [off-list ref] writes:
On Mon, Mar 05, 2012 at 02:04:37PM +0100, Thomas Rast wrote:
quoted
René Haber [off-list ref] writes:
quoted
sh -c '                                   
   . /sw/lib/git-core/git-sh-setup
    get_author_ident_from_commit 16b94413cbce12531e8f946286851598449d3913
 '
GIT_AUTHOR_NAME='Ren'é Haber
GIT_AUTHOR_EMAIL='rene@habr.de'
GIT_AUTHOR_DATE='@1329212923 +0100'
[...]
That is, the garbage (if you try to read it as UTF-8) in the printf
string was matched and replaced byte-by-byte with 'x'.  However,
Will was getting the unreplaced results

  0000000: f89d 849e 0a                             .....

I'm not sure he has followed up on that problem; the only hope may be to
get a better 'sed'.
[...]
It would be nice if the --pretty format placeholders had a "shell-quote"
modifier, and we could just do:

  git show --format='GIT_AUTHOR_NAME=%(an:shell)'

or something similar. for-each-ref knows about shell-quoting, but we
can't use it here, because we are looking at arbitrary commits, not just
ones pointed to by refs.
Perhaps by using %an etc., line numbers and --sq-quote:

  $ git rev-list --no-walk --date=raw --format="%an%n%ae%n%ad" --encoding=UTF-8 HEAD |
    while read -r s; do git rev-parse --sq-quote "$s"; done |
    sed -n -e '2s/^ /GIT_AUTHOR_NAME=/p' -e '3s/^ /GIT_AUTHOR_EMAIL=/p' -e '4s/^ /GIT_AUTHOR_DATE=/p'
  GIT_AUTHOR_NAME='Thom'\''as Ràst'
  GIT_AUTHOR_EMAIL='trast@inf.ethz.ch'
  GIT_AUTHOR_DATE='1330935546 +0100'

This is for a commit where I deliberately mangled my author line to make
an interesting example, as in

  $ git cat-file commit HEAD | grep ^author
  author Thom'as Ràst [off-list ref] 1330935546 +0100

I tried doing the quoting inside sed instead of the while...rev-parse
--sq-quote, but it made my head hurt.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

Re: Bug: pull --rebase with é in name

From: Jeff King <hidden>
Date: 2016-06-15 22:53:13

On Mon, Mar 05, 2012 at 02:40:34PM +0100, Thomas Rast wrote:
quoted
It would be nice if the --pretty format placeholders had a "shell-quote"
modifier, and we could just do:

  git show --format='GIT_AUTHOR_NAME=%(an:shell)'

or something similar. for-each-ref knows about shell-quoting, but we
can't use it here, because we are looking at arbitrary commits, not just
ones pointed to by refs.
Perhaps by using %an etc., line numbers and --sq-quote:

  $ git rev-list --no-walk --date=raw --format="%an%n%ae%n%ad" --encoding=UTF-8 HEAD |
    while read -r s; do git rev-parse --sq-quote "$s"; done |
    sed -n -e '2s/^ /GIT_AUTHOR_NAME=/p' -e '3s/^ /GIT_AUTHOR_EMAIL=/p' -e '4s/^ /GIT_AUTHOR_DATE=/p'
  GIT_AUTHOR_NAME='Thom'\''as Ràst'
  GIT_AUTHOR_EMAIL='trast@inf.ethz.ch'
  GIT_AUTHOR_DATE='1330935546 +0100'
Yeah, that works. It's a little harder to read than would be ideal, but
should produce the right results (I was initially hesitant to use "read"
because I was worried about newlines in the input. But of course, that's
a non-issue since author ident by definition cannot have newlines in
it).

I think this is a good direction regardless of the sed issue. We end up
parsing ident lines like this in a lot of different places, and I would
not be surprised if they do not all behave exactly the same. Eliminating
one such parser in favor of the standard one in pretty.c seems like a
good thing.

-Peff

PS If you are going to turn that into a real patch, note that your date
   field accidentally drops the "@" specifier that unambiguously marks
   the number as an epoch timestamp.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help