unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* git pre-commit hook for merges (WAS: master has switched from Automake to GNU Make)
@ 2017-04-11 16:25 Noam Postavsky
  2017-04-12  9:30 ` martin rudalics
  2017-04-12 18:26 ` Paul Eggert
  0 siblings, 2 replies; 17+ messages in thread
From: Noam Postavsky @ 2017-04-11 16:25 UTC (permalink / raw)
  To: Yuri Khan; +Cc: martin rudalics, Paul Eggert, emacs-devel, Andreas Schwab

On Tue, Apr 11, 2017 at 11:13 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
>> I always want a merge.  So what do you recommend?  In particular what do
>> you recommend when there are conflicts?  IIUC in that case git does not
>> merge anything but waits till I have resolved the conflicts and tells me
>> to commit them when I'm done.  If, at that moment, I do commit I'm in
>> the same situation with SpecialCasing.txt as before.  Or is there any
>> difference?
>
> Well, I would recommend rebasing, which would solve the
> SpecialCasing.txt problem because your rebased branch would start
> after the problematic file has been committed.
>
> But if you insist on merging, it’s doable, too. Then I guess you
> get a merge conflict,
> resolve it,
> stage the resolved files,
> attempt to commit,
> get a whitespace policy violation,
> say an expletive of your choice,
> see that the violation was not your doing,
> optionally confirm that by looking at the history of the problematic
> file in the branch you’re merging,
> then say “Oh well” and commit bypassing the check.

Perhaps we should change the hook so that it doesn't complain about
problems from merges?

--- i/build-aux/git-hooks/pre-commit
+++ w/build-aux/git-hooks/pre-commit
@@ -25,16 +25,23 @@ LC_ALL=

 . git-sh-setup

+# If we're merging, don't flag problems that came from the other side
+# of the merge.
+head=HEAD
+if [ -f "$GIT_DIR"/MERGE_HEAD ] ; then
+    head=$(cat "$GIT_DIR"/MERGE_HEAD)
+fi
+
 git_diff='git diff --cached --name-only --diff-filter=A'
 ok_chars='\0+[=-=]./0-9A-Z_a-z'
-nbadchars=`$git_diff -z HEAD | tr -d "$ok_chars" | wc -c`
+nbadchars=`$git_diff -z $head | tr -d "$ok_chars" | wc -c`

 if test "$nbadchars" -ne 0; then
   echo "File name does not consist of -+./_ or ASCII letters or digits."
   exit 1
 fi

-for new_name in `$git_diff HEAD`; do
+for new_name in `$git_diff $head`; do
   case $new_name in
     -* | */-*)
       echo "$new_name: File name component begins with '-'."
@@ -53,4 +60,4 @@ nbadchars=
 # tests so that trailing spaces are generated on the fly rather than
 # being committed as source.

-exec git diff-index --check --cached HEAD --
+exec git diff-index --check --cached "$head" --



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-04-30 19:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-11 16:25 git pre-commit hook for merges (WAS: master has switched from Automake to GNU Make) Noam Postavsky
2017-04-12  9:30 ` martin rudalics
2017-04-12 18:26 ` Paul Eggert
2017-04-13  0:13   ` Noam Postavsky
2017-04-13  1:49     ` Paul Eggert
2017-04-13  2:05       ` Noam Postavsky
2017-04-13  6:11         ` Paul Eggert
2017-04-13 20:04           ` Noam Postavsky
2017-04-29 18:00   ` Noam Postavsky
2017-04-29 18:44     ` Paul Eggert
2017-04-29 19:15       ` Eli Zaretskii
2017-04-29 19:54         ` Noam Postavsky
2017-04-29 20:04           ` Eli Zaretskii
2017-04-29 23:25             ` Noam Postavsky
2017-04-30  2:34               ` Eli Zaretskii
2017-04-30 19:35                 ` Noam Postavsky
2017-04-30 19:40                   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).