Skip to content

Commit

Permalink
rerere: convert to use parse_pathspec
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed Jul 15, 2013
1 parent 15b55ae commit 01a10b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 5 additions & 3 deletions builtin/rerere.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "rerere.h"
#include "xdiff/xdiff.h"
#include "xdiff-interface.h"
#include "pathspec.h"

static const char * const rerere_usage[] = {
N_("git rerere [clear | forget path... | status | remaining | diff | gc]"),
Expand Down Expand Up @@ -68,11 +69,12 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
return rerere(flags);

if (!strcmp(argv[0], "forget")) {
const char **pathspec;
struct pathspec pathspec;
if (argc < 2)
warning("'git rerere forget' without paths is deprecated");
pathspec = get_pathspec(prefix, argv + 1);
return rerere_forget(pathspec);
parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD,
prefix, argv + 1);
return rerere_forget(&pathspec);
}

fd = setup_rerere(&merge_rr, flags);
Expand Down
9 changes: 5 additions & 4 deletions rerere.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "resolve-undo.h"
#include "ll-merge.h"
#include "attr.h"
#include "pathspec.h"

#define RESOLVED 0
#define PUNTED 1
Expand Down Expand Up @@ -656,7 +657,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
return 0;
}

int rerere_forget(const char **pathspec)
int rerere_forget(struct pathspec *pathspec)
{
int i, fd;
struct string_list conflict = STRING_LIST_INIT_DUP;
Expand All @@ -667,12 +668,12 @@ int rerere_forget(const char **pathspec)

fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);

unmerge_cache(pathspec);
unmerge_cache(pathspec->raw);
find_conflict(&conflict);
for (i = 0; i < conflict.nr; i++) {
struct string_list_item *it = &conflict.items[i];
if (!match_pathspec(pathspec, it->string, strlen(it->string),
0, NULL))
if (!match_pathspec_depth(pathspec, it->string, strlen(it->string),
0, NULL))
continue;
rerere_forget_one_path(it->string, &merge_rr);
}
Expand Down
4 changes: 3 additions & 1 deletion rerere.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "string-list.h"

struct pathspec;

#define RERERE_AUTOUPDATE 01
#define RERERE_NOAUTOUPDATE 02

Expand All @@ -16,7 +18,7 @@ extern void *RERERE_RESOLVED;
extern int setup_rerere(struct string_list *, int);
extern int rerere(int);
extern const char *rerere_path(const char *hex, const char *file);
extern int rerere_forget(const char **);
extern int rerere_forget(struct pathspec *);
extern int rerere_remaining(struct string_list *);
extern void rerere_clear(struct string_list *);
extern void rerere_gc(struct string_list *);
Expand Down

0 comments on commit 01a10b0

Please sign in to comment.