projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use sigaction and SA_RESTART in read-tree.c; add option in Makefile.
[git.git]
/
diff.c
diff --git
a/diff.c
b/diff.c
index
c815918
..
890bdaa
100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-504,9
+504,9
@@
static void prepare_temp_file(const char *name,
}
if (S_ISLNK(st.st_mode)) {
int ret;
}
if (S_ISLNK(st.st_mode)) {
int ret;
- char
*buf, buf_[1024];
- buf = ((sizeof(buf_) < st.st_size) ?
-
xmalloc(st.st_size) : buf_
);
+ char
buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
+ if (sizeof(buf) <= st.st_size)
+
die("symlink too long: %s", name
);
ret = readlink(name, buf, st.st_size);
if (ret < 0)
die("readlink(%s)", name);
ret = readlink(name, buf, st.st_size);
if (ret < 0)
die("readlink(%s)", name);
@@
-555,6
+555,8
@@
static void remove_tempfile(void)
static void remove_tempfile_on_signal(int signo)
{
remove_tempfile();
static void remove_tempfile_on_signal(int signo)
{
remove_tempfile();
+ signal(SIGINT, SIG_DFL);
+ raise(signo);
}
/* An external diff command takes:
}
/* An external diff command takes:
@@
-650,7
+652,7
@@
static void diff_fill_sha1_info(struct diff_filespec *one)
if (DIFF_FILE_VALID(one)) {
if (!one->sha1_valid) {
struct stat st;
if (DIFF_FILE_VALID(one)) {
if (!one->sha1_valid) {
struct stat st;
- if (stat(one->path, &st) < 0)
+ if (
l
stat(one->path, &st) < 0)
die("stat %s", one->path);
if (index_path(one->sha1, one->path, &st, 0))
die("cannot hash %s\n", one->path);
die("stat %s", one->path);
if (index_path(one->sha1, one->path, &st, 0))
die("cannot hash %s\n", one->path);
@@
-723,7
+725,7
@@
static void run_diff(struct diff_filepair *p, struct diff_options *o)
if (memcmp(one->sha1, two->sha1, 20)) {
char one_sha1[41];
if (memcmp(one->sha1, two->sha1, 20)) {
char one_sha1[41];
- int abbrev = o->full_index ? 40 : D
IFF_DEFAULT_INDEX
_ABBREV;
+ int abbrev = o->full_index ? 40 : D
EFAULT
_ABBREV;
memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
len += snprintf(msg + len, sizeof(msg) - len,
memcpy(one_sha1, sha1_to_hex(one->sha1), 41);
len += snprintf(msg + len, sizeof(msg) - len,
@@
-787,7
+789,7
@@
int diff_setup_done(struct diff_options *options)
* so it is safe for us to do this here. Also
* it does not smudge active_cache or active_nr
* when it fails, so we do not have to worry about
* so it is safe for us to do this here. Also
* it does not smudge active_cache or active_nr
* when it fails, so we do not have to worry about
- * cleaning it up ou
f
selves either.
+ * cleaning it up ou
r
selves either.
*/
read_cache();
}
*/
read_cache();
}
@@
-846,9
+848,14
@@
int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if (!strcmp(arg, "--find-copies-harder"))
options->find_copies_harder = 1;
else if (!strcmp(arg, "--abbrev"))
else if (!strcmp(arg, "--find-copies-harder"))
options->find_copies_harder = 1;
else if (!strcmp(arg, "--abbrev"))
- options->abbrev = D
IFF_D
EFAULT_ABBREV;
- else if (!strncmp(arg, "--abbrev=", 9))
+ options->abbrev = DEFAULT_ABBREV;
+ else if (!strncmp(arg, "--abbrev=", 9))
{
options->abbrev = strtoul(arg + 9, NULL, 10);
options->abbrev = strtoul(arg + 9, NULL, 10);
+ if (options->abbrev < MINIMUM_ABBREV)
+ options->abbrev = MINIMUM_ABBREV;
+ else if (40 < options->abbrev)
+ options->abbrev = 40;
+ }
else
return 0;
return 1;
else
return 0;
return 1;
@@
-956,7
+963,7
@@
void diff_free_filepair(struct diff_filepair *p)
}
/* This is different from find_unique_abbrev() in that
}
/* This is different from find_unique_abbrev() in that
- * it
needs to deal with 0{40} SHA1
.
+ * it
stuffs the result with dots for alignment
.
*/
const char *diff_unique_abbrev(const unsigned char *sha1, int len)
{
*/
const char *diff_unique_abbrev(const unsigned char *sha1, int len)
{
@@
-966,16
+973,8
@@
const char *diff_unique_abbrev(const unsigned char *sha1, int len)
return sha1_to_hex(sha1);
abbrev = find_unique_abbrev(sha1, len);
return sha1_to_hex(sha1);
abbrev = find_unique_abbrev(sha1, len);
- if (!abbrev) {
- if (!memcmp(sha1, null_sha1, 20)) {
- char *buf = sha1_to_hex(null_sha1);
- if (len < 37)
- strcpy(buf + len, "...");
- return buf;
- }
- else
- return sha1_to_hex(sha1);
- }
+ if (!abbrev)
+ return sha1_to_hex(sha1);
abblen = strlen(abbrev);
if (abblen < 37) {
static char hex[41];
abblen = strlen(abbrev);
if (abblen < 37) {
static char hex[41];