summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2010-03-13rebase: invoke post-rewrite hookThomas Rast
We have to deal with two separate code paths: a normal rebase, which actually goes through git-am; and rebase {-m|-s}. The only small issue with both is that they need to remember the original sha1 across a possible conflict resolution. rebase -m already puts this information in $dotest/current, and we just introduce a similar file for git-am. Note that in git-am, the hook really only runs when coming from git-rebase: the code path that sets the $dotest/original-commit file is guarded by a test for $dotest/rebasing. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13commit --amend: invoke post-rewrite hookThomas Rast
The rough structure of run_rewrite_hook() comes from run_receive_hook() in receive-pack. We introduce a --no-post-rewrite option and use it to avoid the hook when called from git-rebase -i 'edit'. The next patch will add full support in git-rebase, and we only want to invoke the hook once. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13Documentation: document post-rewrite hookThomas Rast
This defines the behaviour of the post-rewrite hook support, which will be implemented in the following patches. We deliberately do not document how often the hook will be invoked per rewriting command, but the interface is designed to keep that at "once". This would currently not matter too much, since both rebase and filter-branch are shellscripts and spawn many processes anyway. However, when a fast sequencer in C is implemented, it will be beneficial to only have to run the hook once. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13Support showing notes from more than one notes treeThomas Rast
With this patch, you can set notes.displayRef to a glob that points at your favourite notes refs, e.g., [notes] displayRef = refs/notes/* Then git-log and friends will show notes from all trees. Thanks to Junio C Hamano for lots of feedback, which greatly influenced the design of the entire series and this commit in particular. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13test-lib: unset GIT_NOTES_REF to stop it from influencing testsThomas Rast
Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-23Merge branch 'il/rev-glob'Junio C Hamano
2010-02-14builtin-notes: Add "copy" subcommand for copying notes between objectsJohan Herland
This is useful for keeping notes to objects that are being rewritten by e.g. 'git commit --amend', 'git rebase', or 'git cherry-pick'. "git notes copy <from> <to>" is in practice equivalent to "git notes add -C $(git notes list <from>) <to>", although it is somewhat more convenient for regular users. "git notes copy" takes the same -f option as "git add", to overwrite existing notes at the target (instead of aborting with an error message). If the <from>-object has no notes, "git notes copy" will abort with an error message. The patch includes tests verifying correct behaviour of the new subcommand. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Misc. refactoring of argc and exit value handlingJohan Herland
This is in preparation of future patches that add additional subcommands. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add -c/-C options for reusing notesJohan Herland
Inspired by the -c/-C options to "git commit", we teach these options to "git notes add/append" to allow reuse of note objects. With this patch in place, it is now easy to copy or move notes between objects. For example, to copy object A's notes to object B: git notes add [-f] -C $(git notes list A) B To move instead of copying, you simply remove the notes from the source object afterwards, e.g.: git notes remove A The patch includes tests verifying correct behaviour of the new functionality. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Refactor handling of -F option to allow combining -m and -FJohan Herland
By moving the -F option handling into a separate function (parse_file_arg), we can start allowing several -F options, and mixed usage of -m and -F options. Each -m/-F given appends to the note message, in the order they are given on the command-line. The patch includes tests verifying correct behaviour of the new functionality. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Deprecate the -m/-F options for "git notes edit"Johan Herland
The semantics for "git notes edit -m/-F" overlap with those for "git notes add -f", and the behaviour (i.e. overwriting existing notes with the given message/file) is more intuitively captured by (and better documented with) "git notes add -f". Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add "append" subcommand for appending to note objectsJohan Herland
"git notes append" is equivalent to "git notes edit" except that instead of editing existing notes contents, you can only append to it. This is useful for quickly adding annotations like e.g.: git notes append -m "Acked-by: A U Thor <author@example.com>" "git notes append" takes the same -m/-F options as "git notes add". If there is no existing note to append to, "git notes append" is identical to "git notes add" (i.e. it adds a new note). The patch includes tests verifying correct behaviour of the new subcommand. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add "add" subcommand for adding notes to objectsJohan Herland
"git notes add" is identical to "git notes edit" except that instead of editing existing notes for a given object, you can only add notes to an object that currently has none. If "git notes add" finds existing notes for the given object, the addition is aborted. However, if the new -f/--force option is used, "git notes add" will _overwrite_ the existing notes with the new notes contents. If there is no existing notes for the given object. "git notes add" is identical to "git notes edit" (i.e. it adds a new note). The patch includes tests verifying correct behaviour of the new subcommand. Suggested-by: Joey Hess <joey@kitenet.net> Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add --message/--file aliases for -m/-F optionsJohan Herland
Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add "list" subcommand for listing note objectsJohan Herland
"git notes list" will list all note objects in the current notes ref (in the format "<note object> <annotated object>"). "git notes list <object>" will list the note object associated with the given <object>, or fail loudly if the given <object> has no associated notes. If no arguments are given to "git notes", it defaults to the "list" subcommand. This is for pseudo-compatibility with "git tag" and "git branch". The patch includes tests verifying correct behaviour of the new subcommand. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Documentation: Generalize git-notes docs to 'objects' instead of 'commits'Johan Herland
Notes can annotate arbitrary objects (not only commits), but this is not reflected in the current documentation. This patch rewrites the git-notes documentation to talk about 'objects' instead of 'commits'. However, the discussion on commit notes and how they are displayed by 'git log' is largely preserved. Finally, I add myself to the Author/Documentation credits, since most of the lines in the git-notes code and docs are blamed on me. Cc: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add "prune" subcommand for removing notes for missing objectsJohan Herland
"git notes prune" will remove all notes that annotate unreachable/non- existing objects. The patch includes tests verifying correct behaviour of the new subcommand. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: prune_notes(): Prune notes that belong to non-existing objectsJohan Herland
When an object is made unreachable by Git, any notes that annotate that object are not automagically made unreachable, since all notes are always trivially reachable from a notes ref. In order to remove notes for non-existing objects, we therefore need to add functionality for traversing the notes tree and explicitly removing references to notes that annotate non-reachable objects. Thus the notes objects themselves also become unreachable, and are removed by a later garbage collect. prune_notes() performs this traversal (by using for_each_note() internally), and removes the notes in question from the notes tree. Note that the effect of prune_notes() is not persistent unless a subsequent call to write_notes_tree() is made. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14t3305: Verify that removing notes triggers automatic fanout consolidationJohan Herland
Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14builtin-notes: Add "remove" subcommand for removing existing notesJohan Herland
Using "git notes remove" is equivalent to specifying an empty note message. The patch includes tests verifying correct behaviour of the new subcommand. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Teach builtin-notes to remove empty notesJohan Herland
When the result of editing a note is an empty string, the associated note entry should be deleted from the notes tree. This allows deleting notes by invoking either "git notes -m ''" or "git notes -F /dev/null". Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Teach notes code to properly preserve non-notes in the notes treeJohan Herland
The note tree structure allows for non-note entries to coexist with note entries in a notes tree. Although we certainly expect there to be very few non-notes in a notes tree, we should still support them to a certain degree. This patch teaches the notes code to preserve non-notes when updating the notes tree with write_notes_tree(). Non-notes are not affected by fanout restructuring. For non-notes to be handled correctly, we can no longer allow subtree entries that do not match the fanout structure produced by the notes code itself. This means that fanouts like 4/36, 6/34, 8/32, 4/4/32, etc. are no longer recognized as note subtrees; only 2-based fanouts are allowed (2/38, 2/2/36, 2/2/2/34, etc.). Since the notes code has never at any point _produced_ non-2-based fanouts, it is highly unlikely that this change will cause problems for anyone. The patch also adds some tests verifying the correct handling of non-notes in a notes tree. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14t3305: Verify that adding many notes with git-notes triggers increased fanoutJohan Herland
Add a test verifying that the notes code automatically restructures the notes tree into a deeper fanout level, when many notes are added with "git notes". Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14t3301: Verify successful annotation of non-commitsJohan Herland
Adds a testcase verifying that git-notes works successfully on tree, blob, and tag objects. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Builtin-ify git-notesJohan Herland
The builtin-ification includes some minor behavioural changes to the command-line interface: It is no longer allowed to mix the -m and -F arguments, and it is not allowed to use multiple -F options. As part of the builtin-ification, we add the commit_notes() function to the builtin API. This function (together with the notes.h API) can be easily used from other builtins to manipulate the notes tree. Also includes needed changes to t3301. This patch has been improved by the following contributions: - Stephen Boyd: Use die() instead of fprintf(stderr, ...) followed by exit(1) Cc: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Refactor notes concatenation into a flexible interface for combining notesJohan Herland
When adding a note to an object that already has an existing note, the current solution is to concatenate the contents of the two notes. However, the caller may instead wish to _overwrite_ the existing note with the new note, or maybe even _ignore_ the new note, and keep the existing one. There might also be other ways of combining notes that are only known to the caller. Therefore, instead of unconditionally concatenating notes, we let the caller specify how to combine notes, by passing in a pointer to a function for combining notes. The caller may choose to implement its own function for notes combining, but normally one of the following three conveniently supplied notes combination functions will be sufficient: - combine_notes_concatenate() combines the two notes by appending the contents of the new note to the contents of the existing note. - combine_notes_overwrite() replaces the existing note with the new note. - combine_notes_ignore() keeps the existing note, and ignores the new note. A combine_notes function can be passed to init_notes() to choose a default combine_notes function for that notes tree. If NULL is given, the notes tree falls back to combine_notes_concatenate() as the ultimate default. A combine_notes function can also be passed directly to add_note(), to control the notes combining behaviour for a note addition in particular. If NULL is passed, the combine_notes function registered for the given notes tree is used. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: Allow multiple concurrent notes trees with new struct notes_treeJohan Herland
The new struct notes_tree encapsulates access to a specific notes tree. It is provided to allow callers to make use of several different notes trees simultaneously. A struct notes_tree * parameter is added to every function in the notes API. In all cases, NULL can be passed, in which case the fallback "default" notes tree (default_notes_tree) is used. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: write_notes_tree(): Store the notes tree in the databaseJohan Herland
Uses for_each_note() to traverse the notes tree, and produces tree objects on the fly representing the "on-disk" version of the notes tree with appropriate fanout. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: for_each_note(): Traverse the entire notes tree with a callbackJohan Herland
This includes a first attempt at creating an optimal fanout scheme (which is calculated on-the-fly, while traversing). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: get_note(): Return the note annotating the given objectJohan Herland
Created by a simple cleanup and rename of lookup_notes(). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: remove_note(): Remove note objects from the notes tree structureJohan Herland
This includes adding internal functions for maintaining a healthy notes tree structure after removing individual notes. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: add_note(): Add note objects to the internal notes tree structureJohan Herland
Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: init_notes(): Initialize the notes tree from the given notes refJohan Herland
Created by a simple refactoring of initialize_notes(). Also add a new 'flags' parameter, which is a bitwise combination of notes initialization flags. For now, there is only one flag - NOTES_INIT_EMPTY - which indicates that the notes tree should not auto-load the contents of the given (or default) notes ref, but rather should leave the notes tree initialized to an empty state. This will become useful in the future when manipulating the notes tree through the notes API. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Add tests for checking correct handling of $GIT_NOTES_REF and core.notesRefJohan Herland
Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Notes API: get_commit_notes() -> format_note() + remove the commit restrictionJohan Herland
There is really no reason why only commit objects can be annotated. By changing the struct commit parameter to get_commit_notes() into a sha1 we gain the ability to annotate any object type. To reflect this in the function naming as well, we rename get_commit_notes() to format_note(). This patch also fixes comments and variable names throughout notes.c as a consequence of the removal of the unnecessary 'commit' restriction. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14Minor cosmetic fixes to notes.cJohan Herland
Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-23Merge branch 'jc/maint-limit-note-output'Junio C Hamano
* jc/maint-limit-note-output: Fix "log --oneline" not to show notes Fix "log" family not to be too agressive about showing notes
2010-01-23Merge branch 'nd/ls-files-sparse-fix'Junio C Hamano
* nd/ls-files-sparse-fix: Fix memory corruption when .gitignore does not end by \n
2010-01-22Make difftool.prompt fall back to mergetool.promptSebastian Schuberth
The documentation states that "git-difftool falls back to git-mergetool config variables when the difftool equivalents have not been defined". Until now, this was not the case for "difftool.prompt". Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22engine.pl: Fix a recent breakage of the buildsystem generatorRamsay Jones
Commit ade2ca0c (Do not try to remove directories when removing old links, 2009-10-27) added an expression to a 'test' using an '-o' or connective. This resulted in the buildsystem generator mistaking a conditional 'rm' for a linker command. In order to fix the breakage, we filter out all 'test' commands before then attempting to identify the commands of interest. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22git-mv: fix moving more than one source to a single destinationJunio C Hamano
The code used as if return value from basename(3) were stable, but often the function is implemented to return a pointer to a static storage internal to it. Because basename(3) is also allowed to modify its input parameter in place, casting constness away from the strings we obtained from the caller and giving them to basename is a no-no. Reported, and initial fix and test supplied by David Rydh. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22rebase -i: Enclose sed command substitution in quotesMichael Haggerty
Reported by: Johannes Sixt <j.sixt@viscovery.net> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22rebase -i: Avoid non-portable "test X -a Y"Michael Haggerty
Reported by: Eric Blake <ebb9@byu.net> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "index-pack" a built-inLinus Torvalds
This required some fairly trivial packfile function 'const' cleanup, since the builtin commands get a const char *argv[] array. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "git pack-redundant" a built-inLinus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "git unpack-file" a built-inLinus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "mktag" a built-inLinus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "merge-index" a built-inLinus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22merge-tree: remove unnecessary call of git_extract_argv0_pathJohannes Sixt
This call should have been removed when the utility was made a builtin by 907a7cb. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "git patch-id" a built-inLinus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>