This also regularizes the make. The source files themselves don't get
the "git-" prefix, because that's just inconvenient. So instead we just
make the rule that "git-xxxx" depends on "xxxx.c", and do that for
all the core programs (ie the old "git-mktag.c" got renamed to just
"mktag.c" to match everything else).
And "show-diff" got renamed to "git-diff-files" while at it, since
that's what it really should be to match the other git-diff-xxx cases.
With the recent "no-patch-by-default" change, the -s flag to the
show-diff command (and silent variable in the show-diff.c) became
meaningless. This deprecates it.
Cogito uses "show-diff -s" for the purpose of "I do not want the patch
text. I just want to know if something has potentially changed, in
which case I know you will have some output. I'll run update-cache
--refresh if you say something", so we cannot barf on seeing -s on our
command line yet.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This uses the reworked diff interface to generate patches directly out
of show-diff when -p is specified.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This reworks the diff-tree-helper and show-diff to further make external
diff command interface simpler.
These commands now honor GIT_EXTERNAL_DIFF environment variable which
can point at an arbitrary program that takes 7 parameters:
name file1 file1-sha1 file1-mode file2 file2-sha1 file2-mode
The parameters for an external diff command are as follows:
name this invocation of the command is to emit diff
for the named cache/tree entry.
file1 pathname that holds the contents of the first
file. This can be a file inside the working
tree, or a temporary file created from the blob
object, or /dev/null. The command should not
attempt to unlink it -- the temporary is
unlinked by the caller.
file1-sha1 sha1 hash if file1 is a blob object, or "."
otherwise.
file1-mode mode bits for file1, or "." for a deleted file.
If GIT_EXTERNAL_DIFF environment variable is not set, the
default is to invoke diff with the set of parameters old
show-diff used to use. This built-in implementation honors the
GIT_DIFF_CMD and GIT_DIFF_OPTS environment variables as before.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
With this patch, the non-core'ish part of show-diff command that
invokes an external "diff" comand to obtain patches is split
into a separate file. The next patch will introduce a new
command, diff-tree-helper, which uses this common diff interface
to format diff-tree and diff-cache output into a patch form.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Patch 1/6 in the series has already cleaned the interface to
call sq_expand(), but the comment before that function still
carries the stale interface warning. Remove it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This adds -R option to obtain reverse diff.
It may be useful in the merge workflow. After the base of the working
directory is merged and commited, in the working directory:
$ read-tree <tree-id-of-merged-tree>
$ show-diff -R
to re-validate if upstream changes make sense, and/or revert or
conflict with local changes you have in the working files.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This makes the diff output formatting options customizable via the
environment variables. The default is still the Linux kernel style.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch adjusts the default output format of show-diff to match
the Linux kernel style, recommended in Documentation/SubmittingPatches.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch removes the custom diff generation code from the
show_diff_empty() function. Instead, just use show_differences().
This reduces the code size; but more importantly, it is needed for
the later patch to give diff options.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch fixes show-diff to detect unreadable blob and warn
instead of going ahead and crashing.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch fixes sq_expand() and show_differences() not to use and
hold onto its privately allocated buffer, which was a misguided
attempt to reduce calls to malloc but made later changes harder.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The patch to introduce shell safety to show-diff has an
off-by-one error. Here is an fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This is my bad. I added #include <ctype.h> to the file,
which I ended up not using and failed to remove it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
When run on unmerged dircache, show-diff compares the working
file with each non-empty stage for that path. Two out of three
times, this is not very helpful. This patch makes it report the
unmergedness only once per each path and avoids running the
actual diff.
Upper layer SCMs like Cogito are expected to find out mode/SHA1
for each stage by using "show-files --stage" and run the diff
itself. This would result in more sensible diffs.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This fixes some stylistic problems introduced by my previous set
of patches. I'll be sending my last patch to show-diff next,
which depends on this cleanup.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The show-diff command uses a variable "new" but it is always
used to point at the original data recorded in the dircache
before the user started editing in the working file. Rename it
to "old" to avoid confusion.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The command line for running "diff" command is built without
taking shell metacharacters into account. A malicious dircache
entry "foo 2>bar" (yes, a filename with space) would result in
creating a file called "bar" with the error message "diff: foo:
No such file or directory" in it.
This is not just a user screwing over himself. Such a dircache
can be created as a result of a merge with tree from others.
Here is a fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch adds the -z option to the show-diff command,
primarily for use by scripts. The information emitted is
similar to that of -q option, but in a more machine readable
form. Records are terminated with NUL instead of LF, so that
the scripts can deal with pathnames with embedded newlines.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
SCMs have ways to say "I want diff only this particular file",
or "I want diff files under this directory". This patch teaches
show-diff to do something similar. Without command line
arguments, it still examines everything in the dircache as
before.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This adds the '-q' option for show-diff.c to squelch complaints for
missing files.
It is handy if you want to run it in the merge temporary directory after
running merge-trees with its minimum checkout mode, which is the
default, because you would not find any files other than the ones that
needs human validation after the merge there.
It also fixes the argument parsing bug Paul Mackerras noticed in
<16991.42305.118284.139777@cargo.ozlabs.ibm.com> but slightly
differently.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This allows using a git tree over NFS with different byte order, and
makes it possible to just copy a fully populated repository and have
the end result immediately usable (needing just a refresh to update
the stat information).
My convention is that contrary to files trimmed to zero size,
deleted files always go to /dev/null. This patch turns show-diff
to abide this.
Signed-off-by: Petr Baudis <pasky@ucw.cz>
This patch adds a -s flag for show-diff, which will surpress the
actual diffing. This is useful for my scripts when they just want
to see what needs to be updated in the cache.
Signed-off-by: Petr Baudis <pasky@ucw.cz>
The ideas is that using the show-diff to generate the
patch including deleted and new file (in the next patch).
So we don't have to do the temp new file diff dance on the
script.
The cache index now contain enough information to generate
the whole patch. So the GIT SCM don't need separate command
for check out file to edit or delete. Just do the edit and
remove and GIT will generate the correct patch.
It still require tell GIT to add new files.
The tool interface sucks (especially "committing" information, which is just
me doing everything by hand from the command line), but I think this is in
theory actually a viable way of describing the world. So copyright it.