summaryrefslogtreecommitdiff
path: root/builtin-revert.c
AgeCommit message (Collapse)Author
2008-03-03revert: actually check for a dirty indexJeff King
The previous code mistakenly used wt_status_prepare to check whether the index had anything commitable in it; however, that function is just an init function, and will never report a dirty index. The correct way with wt_status_* would be to call wt_status_print with the output pointing to /dev/null or similar. However, that does extra work by both examining the working tree and spewing status information to nowhere. Instead, let's just implement the useful subset of wt_status_print as an "is_index_dirty" function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-16Improve use of lockfile APIBrandon Casey
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30Mention that git-rm can be an appropriate resolution as well as git-add.David Symonds
Especially when using git-cherry-pick, removing files that are unmerged can be a logical action. This patch merely changes the informative text to be less confusing. Signed-off-by: David Symonds <dsymonds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30revert/cherry-pick: Allow overriding the help text by the calling PorcelainWincent Colaiuta
A Porcelain command that uses cherry-pick or revert may make a commit out of resolved index itself, in which case telling the user to commit the result is not appropriate at all. This allows GIT_CHERRY_PICK_HELP environment variable to be set by the calling Porcelain in order to override the built-in help text. [jc: this is heavily modified from the original but should be equivalent in spirit] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-25revert/cherry-pick: do not mention the original refJunio C Hamano
When you cherry-pick or revert a commit, naming it with an annotated tag, we added a comment, attempting to repeat what we got from the end user, to the message. But this was inconsistent. When we got "cherry-pick branch", we recorded the object name (40-letter SHA-1) without saying anything like "original was 'branch'". There was no need to. Also recent rewrite to use parse-options made it impossible to parrot the original command line without "unparsing". This removes the code that implements the misguided "we dereferenced the tag so record that in the commit message" behaviour. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14Merge branch 'maint'Junio C Hamano
* maint: git-clean: honor core.excludesfile Documentation: Fix man page breakage with DocBook XSL v1.72 git-remote.txt: fix typo core-tutorial.txt: Fix argument mistake in an example. replace reference to git-rm with git-reset in git-commit doc Grammar fixes for gitattributes documentation Don't allow fast-import tree delta chains to exceed maximum depth revert/cherry-pick: allow starting from dirty work tree. t/t3404: fix test for a bogus todo file. Conflicts: fast-import.c
2007-11-13Resurrect git-revert.sh example and add comment to builtin-revert.cJunio C Hamano
I had to scratch my head for quite some time figuring out why we cannot optimize out write_tree() we do when --no-commit option is given, whose purpose seem to be only to check if the index is unmerged, with a simple loop over the active_cache[]. So add a comment to describe why the write_tree() is there, and resurrect the last scripted version as a reference material in contrib/example directory with others. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-13revert/cherry-pick: allow starting from dirty work tree.Junio C Hamano
There is no reason to forbid a dirty work tree when reverting or cherry-picking a change, as long as the index is clean. The scripted version used to allow it: case "$no_commit" in t) # We do not intend to commit immediately. We just want to # merge the differences in. head=$(git-write-tree) || die "Your index file is unmerged." ;; *) head=$(git-rev-parse --verify HEAD) || die "You do not have a valid HEAD" files=$(git-diff-index --cached --name-only $head) || exit if [ "$files" ]; then die "Dirty index: cannot $me (dirty: $files)" fi ;; esac but C rewrite tightened the check, probably by mistake. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-04Merge branch 'jc/revert-merge'Junio C Hamano
* jc/revert-merge: cherry-pick/revert -m: add tests revert/cherry-pick: work on merge commits as well Conflicts: builtin-revert.c
2007-11-02Merge branch 'ph/parseopt'Junio C Hamano
* ph/parseopt: (24 commits) gc: use parse_options Fixed a command line option type for builtin-fsck.c Make builtin-pack-refs.c use parse_options. Make builtin-name-rev.c use parse_options. Make builtin-count-objects.c use parse_options. Make builtin-fsck.c use parse_options. Update manpages to reflect new short and long option aliases Make builtin-for-each-ref.c use parse-opts. Make builtin-symbolic-ref.c use parse_options. Make builtin-update-ref.c use parse_options Make builtin-revert.c use parse_options. Make builtin-describe.c use parse_options Make builtin-branch.c use parse_options. Make builtin-mv.c use parse-options Make builtin-rm.c use parse_options. Port builtin-add.c to use the new option parser. parse-options: allow callbacks to take no arguments at all. parse-options: Allow abbreviated options when unambiguous Add shortcuts for very often used options. parse-options: make some arguments optional, add callbacks. ... Conflicts: Makefile builtin-add.c
2007-10-31Merge branch 'maint' into HEADJunio C Hamano
* maint: Update GIT 1.5.3.5 Release Notes git-rebase--interactive.sh: Make 3-way merge strategies work for -p. git-rebase--interactive.sh: Don't pass a strategy to git-cherry-pick. Fix --strategy parsing in git-rebase--interactive.sh Make merge-recursive honor diff.renamelimit cherry-pick/revert: more compact user direction message core-tutorial: Use new syntax for git-merge. git-merge: document but discourage the historical syntax Prevent send-pack from segfaulting (backport from 'master') Documentation/git-cvsexportcommit.txt: s/mgs/msg/ in example Conflicts: git-rebase--interactive.sh
2007-10-30cherry-pick/revert: more compact user direction messageNicolas Pitre
A failed cherry-pick (and friend) currently says: |Automatic cherry-pick failed. After resolving the conflicts, |mark the corrected paths with 'git-add <paths>' |and commit the result. This can obviously be displayed on two lines only. While at it, change "git-add" to "git add". Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-30Make builtin-revert.c use parse_options.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-27revert/cherry-pick: work on merge commits as wellJunio C Hamano
Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline (iow, what change to reverse). With this patch, cherry-pick and revert learn -m (--mainline) option that lets you specify the parent number (starting from 1) of the mainline, so that you can: git revert -m 1 $merge to reverse the changes introduced by the $merge commit relative to its first parent, and: git cherry-pick -m 2 $merge to replay the changes introduced by the $merge commit relative to its second parent. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-19Use xmemdupz() in many places.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-13More staticJunio C Hamano
There still are quite a few symbols that ought to be static. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-08Missing statics.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-05-23Fix command line parameter parser of revert/cherry-pickJunio C Hamano
The parser was inconsistently done, in that it did not look at the last command line parameter to see if it could be an unknown option, although it was designed to notice unknown options if they were given in positions the command expects to find them (i.e. everything except the last parameter, which ought to be <commit-ish>). This prevented a very natural invocation $ git cherry-pick --usage from issuing the usage help. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-10Correct error message in revert/cherry-pickShawn O. Pearce
We now write to MERGE_MSG, not .msg. I missed this earlier when I changed the target we write to. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-09Use .git/MERGE_MSG in cherry-pick/revertShawn O. Pearce
Rather than storing the temporary commit message data in .msg (in the working tree) we now store the message data in .git/MERGE_MSG. By storing the message in the .git/ directory we are sure we will never have a collision with a user file, should a project actually have a ".msg" file in their top level tree. We also don't need to worry about leaving this stale file behind during a `reset --hard` and have it show up in the output of status. We are using .git/MERGE_MSG here to store the temporary message as it is an already established convention between git-merge, git-am and git-rebase that git-commit will default the user's edit buffer to the contents of .git/MERGE_MSG. If the user is going to need to resolve this commit or wants to edit the message on their own prepping that file with the desired message "just works". Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-24git-revert: Revert revert message to old behaviourJohannes Schindelin
When converting from the shell script, based on a misreading of the sed invocation, the builtin included the abbreviated commit name, and did _not_ include the quotes around the oneline message. This fixes it. [jc: with a fix for the typo/thinko spotted by Linus, and also removing the unwanted abbrev at the beginning.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-13Correct new compiler warnings in builtin-revertShawn O. Pearce
The new builtin-revert code introduces a few new compiler errors when I'm building with my stricter set of checks enabled in CFLAGS. These all just stem from trying to store a constant string into a non-const char*. Simple fix, make the variables const char*. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-12Switch to run_command_v_opt in revertShawn O. Pearce
Another change by me is removing the va_list variants of run_command, one of which is used by builtin-revert.c. To avoid compile errors I'm refactoring builtin-revert to use the char** variant instead, as that variant is staying. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06cherry-pick: Bug fix 'cherry picked from' message.Shawn O. Pearce
Somewhere along the line (in abd6970a) git-revert.sh learned to omit the private object name from the new commit message *unless* -x was supplied on the command line by the user. The way this was implemented is really non-obvious in the original script. Setting replay=t (the default) means we don't include the the private object name, while setting reply='' (the -x flag) means we should include the private object name. These two settings now relate to the replay=1 and replay=0 cases in the C version, so we need to negate replay to test it is 0. I also noticed the C version was adding an extra LF in the -x case, where the older git-revert.sh was not. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-04cherry-pick: Suggest a better method to retain authorshipJohannes Schindelin
When a cherry-pick failed, we used to recommend setting environment variables to retain the authorship. It is much easier, though, to use the "-c" flag of git-commit. Print this message also when merge-recursive fails (the code used to exit(1) in that case, never reaching the proper failure path). Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-04Make git-revert & git-cherry-pick a builtinJohannes Schindelin
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>