summaryrefslogtreecommitdiff
path: root/builtin-revert.c
AgeCommit message (Collapse)Author
2009-06-27Use die_errno() instead of die() when checking syscallsThomas Rast
Lots of die() calls did not actually report the kind of error, which can leave the user confused as to the real problem. Use die_errno() where we check a system/library call that sets errno on failure, or one of the following that wrap such calls: Function Passes on error from -------- -------------------- odb_pack_keep open read_ancestry fopen read_in_full xread strbuf_read xread strbuf_read_file open or strbuf_read_file strbuf_readlink readlink write_in_full xwrite Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-31Merge branch 'sb/opt-filename'Junio C Hamano
* sb/opt-filename: parse-opts: add OPT_FILENAME and transition builtins parse-opts: prepare for OPT_FILENAME Conflicts: builtin-log.c
2009-05-25parse-opts: prepare for OPT_FILENAMEStephen Boyd
To give OPT_FILENAME the prefix, we pass the prefix to parse_options() which passes the prefix to parse_options_start() which sets the prefix member of parse_opts_ctx accordingly. If there isn't a prefix in the calling context, passing NULL will suffice. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-19Use 'UTF-8' rather than 'utf-8' everywhere for backward compatibilityBrandon Casey
Some ancient platforms (Solaris 7, IRIX 6.5) do not understand 'utf-8', but all tested implementations understand 'UTF-8'. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-08Merge branch 'maint-1.6.1' into maintJunio C Hamano
* maint-1.6.1: builtin-revert.c: release index lock when cherry-picking an empty commit
2009-03-07builtin-revert.c: release index lock when cherry-picking an empty commitChris Johnsen
When a cherry-pick of an empty commit is done, release the lock held on the index. The fix is the same as was applied to similar code in 4271666046. Signed-off-by: Chris Johnsen <chris_johnsen@pobox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-11Generalize and libify index_is_dirty() to index_differs_from(...)Stephan Beyer
index_is_dirty() in builtin-revert.c checks if the index is dirty. This patch generalizes this function to check if the index differs from a revision, i.e. the former index_is_dirty() behavior can now be achieved by index_differs_from("HEAD", 0). The second argument "diff_flags" allows to set further diff option flags like DIFF_OPT_IGNORE_SUBMODULES. See DIFF_OPT_* macros in diff.h for a list. index_differs_from() seems to be useful for more than builtin-revert.c, so it is moved into diff-lib.c and also used in builtin-commit.c. Yet to mention: - "rev.abbrev = 0;" can be safely removed. This has no impact on performance or functioning of neither setup_revisions() nor run_diff_index(). - rev.pending.objects is free()d because this fixes a leak. (Also see 295dd2ad "Fix memory leak in traverse_commit_list") Mentored-by: Daniel Barkalow <barkalow@iabervon.org> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-22git-revert: record the parent against which a revert was madeRobin Rosenberg
As described in Documentation/howto/revert-a-faulty-merge.txt, re-merging from a previously reverted a merge of a side branch may need a revert of the revert beforehand. Record against which parent the revert was made in the commit, so that later the user can figure out what went on. Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-05Merge branch 'ar/mksnpath'Junio C Hamano
* ar/mksnpath: Use git_pathdup instead of xstrdup(git_path(...)) git_pathdup: returns xstrdup-ed copy of the formatted path Fix potentially dangerous use of git_path in ref.c Add git_snpath: a .git path formatting routine with output buffer Fix potentially dangerous uses of mkpath and git_path Fix potentially dangerous uses of mkpath and git_path Fix mkpath abuse in dwim_ref and dwim_log of sha1_name.c Add mksnpath which allows you to specify the output buffer Conflicts: builtin-revert.c
2008-10-31Merge branch 'maint'Junio C Hamano
* maint: git-svn: change dashed git-commit-tree to git commit-tree Documentation: clarify information about 'ident' attribute bash completion: add doubledash to "git show" Use test-chmtime -v instead of perl in t5000 to get mtime of a file Add --verbose|-v to test-chmtime asciidoc: add minor workaround to add an empty line after code blocks Plug a memleak in builtin-revert Add file delete/create info when we overflow rename_limit Install git-cvsserver in $(bindir) Install git-shell in bindir, too
2008-10-31Merge branch 'ar/maint-mksnpath' into ar/mksnpathJunio C Hamano
* ar/maint-mksnpath: Use git_pathdup instead of xstrdup(git_path(...)) git_pathdup: returns xstrdup-ed copy of the formatted path Fix potentially dangerous use of git_path in ref.c Add git_snpath: a .git path formatting routine with output buffer Conflicts: builtin-revert.c refs.c rerere.c
2008-10-31Use git_pathdup instead of xstrdup(git_path(...))Alex Riesen
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-30Plug a memleak in builtin-revertAlex Riesen
Probably happened when working around git_path's problem with returned buffer being reused. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-22Merge branch 'jc/maint-co-track'Junio C Hamano
* jc/maint-co-track: Enhance hold_lock_file_for_{update,append}() API demonstrate breakage of detached checkout with symbolic link HEAD Fix "checkout --track -b newbranch" on detached HEAD Conflicts: builtin-commit.c
2008-10-19Enhance hold_lock_file_for_{update,append}() APIJunio C Hamano
This changes the "die_on_error" boolean parameter to a mere "flags", and changes the existing callers of hold_lock_file_for_update/append() functions to pass LOCK_DIE_ON_ERROR. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-03cherry-pick/revert: make direct internal call to merge_tree()Miklos Vajna
Refactored merge-recursive interface may still not be ideal but it already allows us to make a direct call to merge_tree(). One regression is that the status message is lost as there is no way to flush them from outside the refactored library code yet. [jc: initial version by Miklos, with moderate amount of fixup by me] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-11Make cherry-pick use rerere for conflict resolution.Abhijit Menon-Sen
Cherry-picking can be helped by reusing previous confliction resolution by invoking rerere automatically. Signed-off-by: Abhijit Menon-Sen <ams@toroid.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-02Merge branch 'maint'Junio C Hamano
2008-08-02builtin-revert.c: typofixStephan Beyer
Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-17Merge branch 'sb/dashless'Junio C Hamano
* sb/dashless: Make usage strings dash-less t/: Use "test_must_fail git" instead of "! git" t/test-lib.sh: exit with small negagive int is ok with test_must_fail Conflicts: builtin-blame.c builtin-mailinfo.c builtin-mailsplit.c builtin-shortlog.c git-am.sh t/t4150-am.sh t/t4200-rerere.sh
2008-07-13Make usage strings dash-lessStephan Beyer
When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-07Allow cherry-picking root commitsJohannes Schindelin
A root commit couldn't be cherry-picked. But its semantics can be defined as simply merging two trees by overlaying disjoint parts and merging overlapping files without any common ancestor. You should be able to rebase originally independent branches on top of another branch by using this. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-14Provide git_config with a callback-data parameterJohannes Schindelin
git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-26Allow cherry-pick (and revert) to add signoff lineDan McGee
I often find myself pulling patches off of other peoples trees using cherry-pick, and following it with an immediate 'git commit --amend -s' command. Eliminate the need for a double commit by allowing signoff on a cherry-pick or revert. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-03Merge branch 'maint'Junio C Hamano
* maint: Update draft release notes for 1.5.4.4 revert: actually check for a dirty index tests: introduce test_must_fail git-submodule: Fix typo 'url' which should be '$url' receive-pack: Initialize PATH to include exec-dir. Conflicts: builtin-revert.c
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-02-22Avoid unnecessary "if-before-free" tests.Jim Meyering
This change removes all obvious useless if-before-free tests. E.g., it replaces code like this: if (some_expression) free (some_expression); with the now-equivalent: free (some_expression); It is equivalent not just because POSIX has required free(NULL) to work for a long time, but simply because it has worked for so long that no reasonable porting target fails the test. Here's some evidence from nearly 1.5 years ago: http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html FYI, the change below was prepared by running the following: git ls-files -z | xargs -0 \ perl -0x3b -pi -e \ 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s' Note however, that it doesn't handle brace-enclosed blocks like "if (x) { free (x); }". But that's ok, since there were none like that in git sources. Beware: if you do use the above snippet, note that it can produce syntactically invalid C code. That happens when the affected "if"-statement has a matching "else". E.g., it would transform this if (x) free (x); else foo (); into this: free (x); else foo (); There were none of those here, either. If you're interested in automating detection of the useless tests, you might like the useless-if-before-free script in gnulib: [it *does* detect brace-enclosed free statements, and has a --name=S option to make it detect free-like functions with different names] http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free Addendum: Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-05Make error messages from cherry-pick/revert more sensibleJunio C Hamano
The original "rewrite in C" did somewhat a sloppy job while stealing code from git-write-tree. The caller pretends as if the write_tree() function would return an error code and being able to issue a sensible error message itself, but write_tree() function just calls die() and never returns an error. Worse yet, the function claims that it was running git-write-tree (which is no longer true after cherry-pick stole it). Tested-by: Björn Steinbrink <B.Steinbrink@gmx.de> 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>