Merge branch 'maint'

* maint:
  Prepare draft release notes to 1.7.4.2
  gitweb: highlight: replace tabs with spaces
  make_absolute_path: return the input path if it points to our buffer
  valgrind: ignore SSE-based strlen invalid reads
  diff --submodule: split into bite-sized pieces
  cherry: split off function to print output lines
  branch: split off function that writes tracking info and commit subject
  standardize brace placement in struct definitions
  compat: make gcc bswap an inline function
  enums: omit trailing comma for portability

Conflicts:
	RelNotes
This commit is contained in:
Junio C Hamano 2011-03-16 16:59:30 -07:00
commit b2f6eab402
27 changed files with 215 additions and 178 deletions

View File

@ -0,0 +1,42 @@
Git v1.7.4.2 Release Notes
==========================
Fixes since v1.7.4.1
--------------------
* Many documentation updates to match "git cmd -h" output and the
git-cmd manual page.
* "git clone /no/such/path" did not fail correctly.
* "git commit" did not correctly error out when the user asked to use a
non existent file as the commit message template.
* "git diff --stat -B" ran on binary files counted the changes in lines,
which was nonsensical.
* "git diff -M" opportunistically detected copies, which was not
necessarily a good thing, especially when it is internally run by
recursive merge.
* "git difftool" didn't tell (g)vimdiff that the files it is reading are
to be opened read-only.
* "git merge" didn't pay attention to prepare-commit-msg hook, even
though if a merge is conflicted and manually resolved, the subsequent
"git commit" would have triggered the hook, which was inconsistent.
* "git patch-id" (and commands like "format-patch --ignore-in-upstream"
that use it as their internal logic) handled changes to files that end
with incomplete lines incorrectly.
* The official value to tell "git push" to push the current branch back
to update the upstream branch it forked from is now called "upstream".
The old name "tracking" is and will be supported.
* gitweb's "highlight" interface mishandled tabs.
* gitweb had a few forward-incompatible syntactic constructs and
also used incorrect variable when showing the file mode in a diff.
And other minor fixes and documentation updates.

View File

@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
char *last_elem = NULL;
struct stat st;
/* We've already done it */
if (path == buf || path == next_buf)
return path;
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
die ("Too long path: %.*s", 60, path);

View File

@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = {
static int patch_interactive, add_interactive, edit_interactive;
static int take_worktree_changes;
struct update_callback_data
{
struct update_callback_data {
int flags;
int add_errors;
};

View File

@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
/*
* Information on commits, used for output.
*/
struct commit_info
{
struct commit_info {
const char *author;
const char *author_mail;
unsigned long author_time;

View File

@ -390,6 +390,30 @@ static int matches_merge_filter(struct commit *commit)
return (is_merged == (merge_filter == SHOW_MERGED));
}
static void add_verbose_info(struct strbuf *out, struct ref_item *item,
int verbose, int abbrev)
{
struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
const char *sub = " **** invalid ref ****";
struct commit *commit = item->commit;
if (commit && !parse_commit(commit)) {
struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit,
&subject, &ctx);
sub = subject.buf;
}
if (item->kind == REF_LOCAL_BRANCH)
fill_tracking_info(&stat, item->name, verbose > 1);
strbuf_addf(out, " %s %s%s",
find_unique_abbrev(item->commit->object.sha1, abbrev),
stat.buf, sub);
strbuf_release(&stat);
strbuf_release(&subject);
}
static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
int abbrev, int current, char *prefix)
{
@ -430,27 +454,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
if (item->dest)
strbuf_addf(&out, " -> %s", item->dest);
else if (verbose) {
struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
const char *sub = " **** invalid ref ****";
commit = item->commit;
if (commit && !parse_commit(commit)) {
struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit,
&subject, &ctx);
sub = subject.buf;
}
if (item->kind == REF_LOCAL_BRANCH)
fill_tracking_info(&stat, item->name, verbose > 1);
strbuf_addf(&out, " %s %s%s",
find_unique_abbrev(item->commit->object.sha1, abbrev),
stat.buf, sub);
strbuf_release(&stat);
strbuf_release(&subject);
}
else if (verbose)
/* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */
add_verbose_info(&out, item, verbose, abbrev);
printf("%s\n", out.buf);
strbuf_release(&name);
strbuf_release(&out);

View File

@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE};
* threads. The producer adds struct work_items to 'todo' and the
* consumers pick work items from the same array.
*/
struct work_item
{
struct work_item {
enum work_type type;
char *name;

View File

@ -13,8 +13,7 @@
static const char index_pack_usage[] =
"git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
struct object_entry
{
struct object_entry {
struct pack_idx_entry idx;
unsigned long size;
unsigned int hdr_size;
@ -44,8 +43,7 @@ struct base_data {
#define FLAG_LINK (1u<<20)
#define FLAG_CHECKED (1u<<21)
struct delta_entry
{
struct delta_entry {
union delta_base base;
int obj_no;
};

View File

@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = {
NULL
};
static void print_commit(char sign, struct commit *commit, int verbose,
int abbrev)
{
if (!verbose) {
printf("%c %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
printf("%c %s %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev),
buf.buf);
strbuf_release(&buf);
}
}
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
commit = list->item;
if (has_commit_patch_id(commit, &ids))
sign = '-';
if (verbose) {
struct strbuf buf = STRBUF_INIT;
struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit,
&buf, &ctx);
printf("%c %s %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev),
buf.buf);
strbuf_release(&buf);
}
else {
printf("%c %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev));
}
print_commit(sign, commit, verbose, abbrev);
list = list->next;
}

View File

@ -585,7 +585,7 @@ extern enum safe_crlf safe_crlf;
enum auto_crlf {
AUTO_CRLF_FALSE = 0,
AUTO_CRLF_TRUE = 1,
AUTO_CRLF_INPUT = -1,
AUTO_CRLF_INPUT = -1
};
extern enum auto_crlf auto_crlf;

View File

@ -68,8 +68,7 @@ enum cmit_fmt {
CMIT_FMT_UNSPECIFIED
};
struct pretty_print_context
{
struct pretty_print_context {
int abbrev;
const char *subject;
const char *after_subject;

View File

@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val)
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define bswap32(x) ({ \
uint32_t __res; \
if (__builtin_constant_p(x)) { \
__res = default_swab32(x); \
} else { \
__asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
} \
__res; })
#define bswap32 git_bswap32
static inline uint32_t git_bswap32(uint32_t x)
{
uint32_t result;
if (__builtin_constant_p(x))
result = default_swab32(x);
else
__asm__("bswap %0" : "=r" (result) : "0" (x));
return result;
}
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))

View File

@ -20,8 +20,7 @@ static int zlib_compression_seen;
const char *config_exclusive_filename = NULL;
struct config_item
{
struct config_item {
struct config_item *next;
char *name;
char *value;

View File

@ -18,7 +18,7 @@ enum action {
CRLF_TEXT,
CRLF_INPUT,
CRLF_CRLF,
CRLF_AUTO,
CRLF_AUTO
};
struct text_stat {

6
diff.c
View File

@ -615,16 +615,14 @@ static void diff_words_append(char *line, unsigned long len,
buffer->text.ptr[buffer->text.size] = '\0';
}
struct diff_words_style_elem
{
struct diff_words_style_elem {
const char *prefix;
const char *suffix;
const char *color; /* NULL; filled in by the setup code if
* color is enabled */
};
struct diff_words_style
{
struct diff_words_style {
enum diff_words_type type;
struct diff_words_style_elem new, old, ctx;
const char *newline;

View File

@ -170,8 +170,7 @@ Format of STDIN stream:
#define DEPTH_BITS 13
#define MAX_DEPTH ((1<<DEPTH_BITS)-1)
struct object_entry
{
struct object_entry {
struct pack_idx_entry idx;
struct object_entry *next;
uint32_t type : TYPE_BITS,
@ -179,16 +178,14 @@ struct object_entry
depth : DEPTH_BITS;
};
struct object_entry_pool
{
struct object_entry_pool {
struct object_entry_pool *next_pool;
struct object_entry *next_free;
struct object_entry *end;
struct object_entry entries[FLEX_ARRAY]; /* more */
};
struct mark_set
{
struct mark_set {
union {
struct object_entry *marked[1024];
struct mark_set *sets[1024];
@ -196,57 +193,49 @@ struct mark_set
unsigned int shift;
};
struct last_object
{
struct last_object {
struct strbuf data;
off_t offset;
unsigned int depth;
unsigned no_swap : 1;
};
struct mem_pool
{
struct mem_pool {
struct mem_pool *next_pool;
char *next_free;
char *end;
uintmax_t space[FLEX_ARRAY]; /* more */
};
struct atom_str
{
struct atom_str {
struct atom_str *next_atom;
unsigned short str_len;
char str_dat[FLEX_ARRAY]; /* more */
};
struct tree_content;
struct tree_entry
{
struct tree_entry {
struct tree_content *tree;
struct atom_str *name;
struct tree_entry_ms
{
struct tree_entry_ms {
uint16_t mode;
unsigned char sha1[20];
} versions[2];
};
struct tree_content
{
struct tree_content {
unsigned int entry_capacity; /* must match avail_tree_content */
unsigned int entry_count;
unsigned int delta_depth;
struct tree_entry *entries[FLEX_ARRAY]; /* more */
};
struct avail_tree_content
{
struct avail_tree_content {
unsigned int entry_capacity; /* must match tree_content */
struct avail_tree_content *next_avail;
};
struct branch
{
struct branch {
struct branch *table_next_branch;
struct branch *active_next_branch;
const char *name;
@ -258,16 +247,14 @@ struct branch
unsigned char sha1[20];
};
struct tag
{
struct tag {
struct tag *next_tag;
const char *name;
unsigned int pack_id;
unsigned char sha1[20];
};
struct hash_list
{
struct hash_list {
struct hash_list *next;
unsigned char sha1[20];
};
@ -278,8 +265,7 @@ typedef enum {
WHENSPEC_NOW
} whenspec_type;
struct recent_command
{
struct recent_command {
struct recent_command *prev;
struct recent_command *next;
char *buf;

View File

@ -1,8 +1,7 @@
#ifndef FETCH_PACK_H
#define FETCH_PACK_H
struct fetch_pack_args
{
struct fetch_pack_args {
const char *uploadpack;
int unpacklimit;
int depth;

View File

@ -1,8 +1,7 @@
#!/bin/sh
echo "/* Automatically generated by $0 */
struct cmdname_help
{
struct cmdname_help {
char name[16];
char help[80];
};

View File

@ -3468,7 +3468,7 @@ sub run_highlighter {
close $fd;
open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
quote_command($highlight_bin).
" --fragment --syntax $syntax |"
" --replace-tabs=8 --fragment --syntax $syntax |"
or die_error(500, "Couldn't open file or run syntax highlighter");
return $fd;
}

View File

@ -82,8 +82,7 @@ static int helper_status;
static struct object_list *objects;
struct repo
{
struct repo {
char *url;
char *path;
int path_len;
@ -108,8 +107,7 @@ enum transfer_state {
COMPLETE
};
struct transfer_request
{
struct transfer_request {
struct object *obj;
char *url;
char *dest;
@ -127,8 +125,7 @@ struct transfer_request
static struct transfer_request *request_queue_head;
struct xml_ctx
{
struct xml_ctx {
char *name;
int len;
char *cdata;
@ -136,8 +133,7 @@ struct xml_ctx
void *userData;
};
struct remote_lock
{
struct remote_lock {
char *url;
char *owner;
char *token;
@ -156,8 +152,7 @@ struct remote_lock
/* Flags that remote_ls passes to callback functions */
#define IS_DIR (1u << 0)
struct remote_ls_ctx
{
struct remote_ls_ctx {
char *path;
void (*userFunc)(struct remote_ls_ctx *ls);
void *userData;

View File

@ -3,8 +3,7 @@
#include "walker.h"
#include "http.h"
struct alt_base
{
struct alt_base {
char *base;
int got_indices;
struct packed_git *packs;
@ -18,8 +17,7 @@ enum object_request_state {
COMPLETE
};
struct object_request
{
struct object_request {
struct walker *walker;
unsigned char sha1[20];
struct alt_base *repo;

15
http.h
View File

@ -42,14 +42,12 @@
#define NO_CURL_IOCTL
#endif
struct slot_results
{
struct slot_results {
CURLcode curl_result;
long http_code;
};
struct active_request_slot
{
struct active_request_slot {
CURL *curl;
FILE *local;
int in_use;
@ -62,8 +60,7 @@ struct active_request_slot
struct active_request_slot *next;
};
struct buffer
{
struct buffer {
struct strbuf buf;
size_t posn;
};
@ -149,8 +146,7 @@ extern int http_fetch_ref(const char *base, struct ref *ref);
extern int http_get_info_packs(const char *base_url,
struct packed_git **packs_head);
struct http_pack_request
{
struct http_pack_request {
char *url;
struct packed_git *target;
struct packed_git **lst;
@ -166,8 +162,7 @@ extern int finish_http_pack_request(struct http_pack_request *preq);
extern void release_http_pack_request(struct http_pack_request *preq);
/* Helpers for fetching object */
struct http_object_request
{
struct http_object_request {
char *url;
char tmpfile[PATH_MAX];
int localfile;

View File

@ -83,10 +83,8 @@ struct rename_df_conflict_info {
* Since we want to write the index eventually, we cannot reuse the index
* for these (temporary) data.
*/
struct stage_data
{
struct
{
struct stage_data {
struct {
unsigned mode;
unsigned char sha[20];
} stages[4];
@ -390,8 +388,7 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
}
}
struct rename
{
struct rename {
struct diff_filepair *pair;
struct stage_data *src_entry;
struct stage_data *dst_entry;
@ -704,8 +701,7 @@ static void update_file(struct merge_options *o,
/* Low level file merging, update and removal */
struct merge_file_info
{
struct merge_file_info {
unsigned char sha[20];
unsigned mode;
unsigned clean:1,

View File

@ -2,8 +2,7 @@
#include "pack.h"
#include "pack-revindex.h"
struct idx_entry
{
struct idx_entry {
off_t offset;
const unsigned char *sha1;
unsigned int nr;

View File

@ -5,8 +5,7 @@ struct string_list_item {
char *string;
void *util;
};
struct string_list
{
struct string_list {
struct string_list_item *items;
unsigned int nr, alloc;
unsigned int strdup_strings:1;

View File

@ -152,17 +152,69 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
die("bad --ignore-submodules argument: %s", arg);
}
static int prepare_submodule_summary(struct rev_info *rev, const char *path,
struct commit *left, struct commit *right,
int *fast_forward, int *fast_backward)
{
struct commit_list *merge_bases, *list;
init_revisions(rev, NULL);
setup_revisions(0, NULL, rev, NULL);
rev->left_right = 1;
rev->first_parent_only = 1;
left->object.flags |= SYMMETRIC_LEFT;
add_pending_object(rev, &left->object, path);
add_pending_object(rev, &right->object, path);
merge_bases = get_merge_bases(left, right, 1);
if (merge_bases) {
if (merge_bases->item == left)
*fast_forward = 1;
else if (merge_bases->item == right)
*fast_backward = 1;
}
for (list = merge_bases; list; list = list->next) {
list->item->object.flags |= UNINTERESTING;
add_pending_object(rev, &list->item->object,
sha1_to_hex(list->item->object.sha1));
}
return prepare_revision_walk(rev);
}
static void print_submodule_summary(struct rev_info *rev, FILE *f,
const char *del, const char *add, const char *reset)
{
static const char format[] = " %m %s";
struct strbuf sb = STRBUF_INIT;
struct commit *commit;
while ((commit = get_revision(rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev->date_mode;
strbuf_setlen(&sb, 0);
if (commit->object.flags & SYMMETRIC_LEFT) {
if (del)
strbuf_addstr(&sb, del);
}
else if (add)
strbuf_addstr(&sb, add);
format_commit_message(commit, format, &sb, &ctx);
if (reset)
strbuf_addstr(&sb, reset);
strbuf_addch(&sb, '\n');
fprintf(f, "%s", sb.buf);
}
strbuf_release(&sb);
}
void show_submodule_summary(FILE *f, const char *path,
unsigned char one[20], unsigned char two[20],
unsigned dirty_submodule,
const char *del, const char *add, const char *reset)
{
struct rev_info rev;
struct commit *commit, *left = left, *right = right;
struct commit_list *merge_bases, *list;
struct commit *left = left, *right = right;
const char *message = NULL;
struct strbuf sb = STRBUF_INIT;
static const char *format = " %m %s";
int fast_forward = 0, fast_backward = 0;
if (is_null_sha1(two))
@ -175,29 +227,10 @@ void show_submodule_summary(FILE *f, const char *path,
!(right = lookup_commit_reference(two)))
message = "(commits not present)";
if (!message) {
init_revisions(&rev, NULL);
setup_revisions(0, NULL, &rev, NULL);
rev.left_right = 1;
rev.first_parent_only = 1;
left->object.flags |= SYMMETRIC_LEFT;
add_pending_object(&rev, &left->object, path);
add_pending_object(&rev, &right->object, path);
merge_bases = get_merge_bases(left, right, 1);
if (merge_bases) {
if (merge_bases->item == left)
fast_forward = 1;
else if (merge_bases->item == right)
fast_backward = 1;
}
for (list = merge_bases; list; list = list->next) {
list->item->object.flags |= UNINTERESTING;
add_pending_object(&rev, &list->item->object,
sha1_to_hex(list->item->object.sha1));
}
if (prepare_revision_walk(&rev))
if (!message &&
prepare_submodule_summary(&rev, path, left, right,
&fast_forward, &fast_backward))
message = "(revision walker failed)";
}
if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
fprintf(f, "Submodule %s contains untracked content\n", path);
@ -221,25 +254,11 @@ void show_submodule_summary(FILE *f, const char *path,
fwrite(sb.buf, sb.len, 1, f);
if (!message) {
while ((commit = get_revision(&rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev.date_mode;
strbuf_setlen(&sb, 0);
if (commit->object.flags & SYMMETRIC_LEFT) {
if (del)
strbuf_addstr(&sb, del);
}
else if (add)
strbuf_addstr(&sb, add);
format_commit_message(commit, format, &sb, &ctx);
if (reset)
strbuf_addstr(&sb, reset);
strbuf_addch(&sb, '\n');
fprintf(f, "%s", sb.buf);
}
print_submodule_summary(&rev, f, del, add, reset);
clear_commit_marks(left, ~0);
clear_commit_marks(right, ~0);
}
strbuf_release(&sb);
}

View File

@ -43,3 +43,9 @@
fun:write_buffer
fun:write_loose_object
}
{
ignore-sse-strlen-invalid-read-size
Memcheck:Addr4
fun:copy_ref
}

View File

@ -12,8 +12,7 @@
static int debug;
struct helper_data
{
struct helper_data {
const char *name;
struct child_process *helper;
FILE *out;