* [PATCH 1/2] Move the pick_author code to git-sh-setup
@ 2007-06-23 23:01 Johannes Schindelin
2007-06-24 6:39 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2007-06-23 23:01 UTC (permalink / raw)
To: git, gitster
At the moment, only git-commit uses that code, to pick the author name,
email and date from a given commit.
This code will be reused in git rebase --interactive.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
git-commit.sh | 30 ++----------------------------
git-sh-setup.sh | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 5547a02..4bef375 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -483,34 +483,8 @@ fi >>"$GIT_DIR"/COMMIT_EDITMSG
# Author
if test '' != "$use_commit"
then
- pick_author_script='
- /^author /{
- s/'\''/'\''\\'\'\''/g
- h
- s/^author \([^<]*\) <[^>]*> .*$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_NAME='\''&'\''/p
-
- g
- s/^author [^<]* <\([^>]*\)> .*$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
-
- g
- s/^author [^<]* <[^>]*> \(.*\)$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_DATE='\''&'\''/p
-
- q
- }
- '
- encoding=$(git config i18n.commitencoding || echo UTF-8)
- set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
- LANG=C LC_ALL=C sed -ne "$pick_author_script"`
- eval "$set_author_env"
- export GIT_AUTHOR_NAME
- export GIT_AUTHOR_EMAIL
- export GIT_AUTHOR_DATE
+ eval $(get_author_ident_from_commit "$use_commit")
+ export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
fi
if test '' != "$force_author"
then
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f24c7f2..d861db3 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -53,6 +53,33 @@ require_work_tree () {
die "fatal: $0 cannot be used without a working tree."
}
+get_author_ident_from_commit () {
+ pick_author_script='
+ /^author /{
+ s/'\''/'\''\\'\'\''/g
+ h
+ s/^author \([^<]*\) <[^>]*> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_NAME='\''&'\''/p
+
+ g
+ s/^author [^<]* <\([^>]*\)> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
+
+ g
+ s/^author [^<]* <[^>]*> \(.*\)$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_DATE='\''&'\''/p
+
+ q
+ }
+ '
+ encoding=$(git config i18n.commitencoding || echo UTF-8)
+ git show -s --pretty=raw --encoding="$encoding" "$1" |
+ LANG=C LC_ALL=C sed -ne "$pick_author_script"
+}
+
if [ -z "$LONG_USAGE" ]
then
LONG_USAGE="Usage: $0 $USAGE"
--
1.5.2.2.279.g74fb3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Move the pick_author code to git-sh-setup
2007-06-23 23:01 [PATCH 1/2] Move the pick_author code to git-sh-setup Johannes Schindelin
@ 2007-06-24 6:39 ` Junio C Hamano
2007-06-24 7:09 ` Junio C Hamano
2007-06-24 10:22 ` Johannes Schindelin
0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-06-24 6:39 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> - set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
> - LANG=C LC_ALL=C sed -ne "$pick_author_script"`
> - eval "$set_author_env"
> ...
> + eval $(get_author_ident_from_commit "$use_commit")
Are you sure about this part of the change? I suspect that you
are losing IFS by not dq'ing the argument you give to the eval.
#!/bin/sh
test1 () {
echo "$1=' d e'"
}
eval $(test1 A)
eval "$(test1 B)"
echo "A=$A"
echo "B=$B"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Move the pick_author code to git-sh-setup
2007-06-24 6:39 ` Junio C Hamano
@ 2007-06-24 7:09 ` Junio C Hamano
2007-06-24 10:22 ` Johannes Schindelin
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-06-24 7:09 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> - set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
>> - LANG=C LC_ALL=C sed -ne "$pick_author_script"`
>> - eval "$set_author_env"
>> ...
>> + eval $(get_author_ident_from_commit "$use_commit")
>
> Are you sure about this part of the change? I suspect that you
> are losing IFS by not dq'ing the argument you give to the eval.
>
> ...
If you care about your data in your variable and do not want
word-splitting at $IFS to happen, you should always dq your
variable. A quick rule of thumb is that the only place that you
can get away by not quoting is straight assignment to another
variable, like so:
var='a b c '
another=$var ;# another="$var" is fine but unnecessary.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Move the pick_author code to git-sh-setup
2007-06-24 6:39 ` Junio C Hamano
2007-06-24 7:09 ` Junio C Hamano
@ 2007-06-24 10:22 ` Johannes Schindelin
2007-06-24 11:14 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2007-06-24 10:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Sat, 23 Jun 2007, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > - set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
> > - LANG=C LC_ALL=C sed -ne "$pick_author_script"`
> > - eval "$set_author_env"
> > ...
> > + eval $(get_author_ident_from_commit "$use_commit")
>
> Are you sure about this part of the change?
No, I am not.
> I suspect that you are losing IFS by not dq'ing the argument you give to
> the eval.
That is well possible. Quoting in shell is such a hassle, and I never seem
to get it right.
Therefore I did a minimal test, namely committing with another
GIT_AUTHOR_NAME (which has spaces in it), and then commiting again, with
"-c HEAD". Which did what I expected: the second commit had the same
author name as the first one.
So I thought that it was okay.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Move the pick_author code to git-sh-setup
2007-06-24 10:22 ` Johannes Schindelin
@ 2007-06-24 11:14 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-06-24 11:14 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> That is well possible. Quoting in shell is such a hassle, and I never seem
> to get it right.
>
> Therefore I did a minimal test,...
>
> So I thought that it was okay.
Try the small test script in the message you are responding to.
It gives me:
$ sh ./1.sh
A= d e
B= d e
A quick rule of thumb is that the only place that you can get
away by not quoting is straight assignment to another variable,
like so:
var='a b c '
another=$var ;# another="$var" is fine but unnecessary.
Similarly for
another=$(some command)
which is Ok not to dquote.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Move the pick_author code to git-sh-setup
2007-06-24 11:09 ` Johannes Schindelin
@ 2007-06-25 0:04 ` Johannes Schindelin
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2007-06-25 0:04 UTC (permalink / raw)
To: Junio C Hamano, Brian Gernhardt; +Cc: git
At the moment, only git-commit uses that code, to pick the author name,
email and date from a given commit.
This code will be reused in git rebase --interactive.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Just the eval was changed, by dq'ing its argument.
git-commit.sh | 30 ++----------------------------
git-sh-setup.sh | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 5547a02..d43bdd8 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -483,34 +483,8 @@ fi >>"$GIT_DIR"/COMMIT_EDITMSG
# Author
if test '' != "$use_commit"
then
- pick_author_script='
- /^author /{
- s/'\''/'\''\\'\'\''/g
- h
- s/^author \([^<]*\) <[^>]*> .*$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_NAME='\''&'\''/p
-
- g
- s/^author [^<]* <\([^>]*\)> .*$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
-
- g
- s/^author [^<]* <[^>]*> \(.*\)$/\1/
- s/'\''/'\''\'\'\''/g
- s/.*/GIT_AUTHOR_DATE='\''&'\''/p
-
- q
- }
- '
- encoding=$(git config i18n.commitencoding || echo UTF-8)
- set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
- LANG=C LC_ALL=C sed -ne "$pick_author_script"`
- eval "$set_author_env"
- export GIT_AUTHOR_NAME
- export GIT_AUTHOR_EMAIL
- export GIT_AUTHOR_DATE
+ eval "$(get_author_ident_from_commit "$use_commit")"
+ export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
fi
if test '' != "$force_author"
then
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f24c7f2..d861db3 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -53,6 +53,33 @@ require_work_tree () {
die "fatal: $0 cannot be used without a working tree."
}
+get_author_ident_from_commit () {
+ pick_author_script='
+ /^author /{
+ s/'\''/'\''\\'\'\''/g
+ h
+ s/^author \([^<]*\) <[^>]*> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_NAME='\''&'\''/p
+
+ g
+ s/^author [^<]* <\([^>]*\)> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
+
+ g
+ s/^author [^<]* <[^>]*> \(.*\)$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_DATE='\''&'\''/p
+
+ q
+ }
+ '
+ encoding=$(git config i18n.commitencoding || echo UTF-8)
+ git show -s --pretty=raw --encoding="$encoding" "$1" |
+ LANG=C LC_ALL=C sed -ne "$pick_author_script"
+}
+
if [ -z "$LONG_USAGE" ]
then
LONG_USAGE="Usage: $0 $USAGE"
--
1.5.2.2.279.g9b198-dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-06-25 0:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-23 23:01 [PATCH 1/2] Move the pick_author code to git-sh-setup Johannes Schindelin
2007-06-24 6:39 ` Junio C Hamano
2007-06-24 7:09 ` Junio C Hamano
2007-06-24 10:22 ` Johannes Schindelin
2007-06-24 11:14 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2007-06-23 23:01 [PATCH 2/2] Teach rebase an interactive mode Johannes Schindelin
2007-06-24 8:15 ` Junio C Hamano
2007-06-24 11:09 ` Johannes Schindelin
2007-06-25 0:04 ` [PATCH 1/2] Move the pick_author code to git-sh-setup Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox