* bug "$message" literal in commit message
@ 2015-06-03 16:51 Yauheni Zablotski
2015-06-03 18:16 ` Junio C Hamano
2015-06-03 18:19 ` Matthieu Moy
0 siblings, 2 replies; 3+ messages in thread
From: Yauheni Zablotski @ 2015-06-03 16:51 UTC (permalink / raw)
To: git
Hello,
I think I found a bug(or strange behavior) in the git.
If commit message contains literal "$message" than that literal
disappears from commit message.
For example:
-------------
user@comp ~/cc $ git commit -am "1$message1"
[master (root-commit) d36a841] 1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1
user@comp ~/cc $ git log
commit d36a841ae25510ada80246a78225446083fcb3e1
Author: user <e.zablotski@gmail.com>
Date: Wed Jun 3 18:21:45 2015 +0200
file
----------------
Sorry for having disturbed you
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bug "$message" literal in commit message
2015-06-03 16:51 bug "$message" literal in commit message Yauheni Zablotski
@ 2015-06-03 18:16 ` Junio C Hamano
2015-06-03 18:19 ` Matthieu Moy
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2015-06-03 18:16 UTC (permalink / raw)
To: Yauheni Zablotski; +Cc: git
Yauheni Zablotski <e.zablotski@gmail.com> writes:
> Hello,
>
> I think I found a bug(or strange behavior) in the git.
> If commit message contains literal "$message" than that literal
> disappears from commit message.
>
> For example:
> -------------
> user@comp ~/cc $ git commit -am "1$message1"
> [master (root-commit) d36a841] 1
> 1 file changed, 0 insertions(+), 0 deletions(-)
> create mode 100644 1
>
> user@comp ~/cc $ git log
> commit d36a841ae25510ada80246a78225446083fcb3e1
> Author: user <e.zablotski@gmail.com>
> Date: Wed Jun 3 18:21:45 2015 +0200
>
> file
> ----------------
>
> Sorry for having disturbed you
Learn shell ;-)
Instead of "git commit -am", try "echo" and repeat your exercise,
and you would see:
$ echo "1$message1"
1
If you prepare a shell variable message1 beforehand, e.g.
$ message1='This is the contents of message1 variable'
$ echo "1$message1"
1This is the contents of message1 variable
Your shell interpolates the value of message1 variable if you write
"$message1" on your command line, way before individual commands
(e.g. echo and git above) that receive the string as its parameter
sees them.
Contrast the above with this invocation after understanding the
above.
$ git commit -a -m '1$message1'
$ git log
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bug "$message" literal in commit message
2015-06-03 16:51 bug "$message" literal in commit message Yauheni Zablotski
2015-06-03 18:16 ` Junio C Hamano
@ 2015-06-03 18:19 ` Matthieu Moy
1 sibling, 0 replies; 3+ messages in thread
From: Matthieu Moy @ 2015-06-03 18:19 UTC (permalink / raw)
To: Yauheni Zablotski; +Cc: git
Yauheni Zablotski <e.zablotski@gmail.com> writes:
> Hello,
>
> I think I found a bug(or strange behavior) in the git.
> If commit message contains literal "$message" than that literal
> disappears from commit message.
>
> For example:
> -------------
> user@comp ~/cc $ git commit -am "1$message1"
Not a Git issue, but a user-error that Git cannot recover.
Your shell is doing the variable expansion before calling git, and
$message1 is considered as a shell variable here. Git does not know that
you used $message1.
Solution:
git commit -am '1$message1'
or
git commit -am "1\$message1"
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-03 18:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-03 16:51 bug "$message" literal in commit message Yauheni Zablotski
2015-06-03 18:16 ` Junio C Hamano
2015-06-03 18:19 ` Matthieu Moy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox