Skip to content

Commit bf113b6

Browse files
lucasderraughCykelero
authored andcommitted
Most GitUp changes, rebased (2025-03-29)
This is a rebase of commit “GitUp. libgit2 updated. v1.3.0 (#7)” (72fd4af) on top of libgit2 v1.9.0. This commit contains most of the GitUp libgit2 fork changes, squashed together. (list below) * scripts: update-xcode has been added. * gitignore: xcode and binaries folders have been excluded. * submodule: submodule dup has been added. * repository: repository update gitlink and repository local config path have been added. * clone: clone into has been added. * refs: reference create virtual and reference symbolic create virtual have been added. * branch: upstream name and upstream remote and upstream merge have been added. * cmake: gitup extensions have been added. * diff: ctime and mtime have been added. * streams: socket a 30 seconds timeout has been added. * ssh: a 30 seconds timeout has been added. * Pass current remote to git_push_negotiation callback. This makes it quite easier to implement the Git 'pre-push' hook. * xpatience and indexer: struct entry has been renamed in favor of fmodules flag.
1 parent 338e6fb commit bf113b6

23 files changed

+459
-18
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
CMakeSettings.json
77
.vs
88
.idea
9+
10+
#GitUp
11+
xcode
12+
binaries

deps/xdiff/xpatience.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*/
4747
struct hashmap {
4848
int nr, alloc;
49-
struct entry {
49+
struct xpatience_hashmap_entry {
5050
unsigned long hash;
5151
/*
5252
* 0 = unused entry, 1 = first line, 2 = second, etc.
@@ -59,7 +59,7 @@ struct hashmap {
5959
* sequence;
6060
* initially, "next" reflects only the order in file1.
6161
*/
62-
struct entry *next, *previous;
62+
struct xpatience_hashmap_entry *next, *previous;
6363

6464
/*
6565
* If 1, this entry can serve as an anchor. See
@@ -165,8 +165,8 @@ static int fill_hashmap(xpparam_t const *xpp, xdfenv_t *env,
165165
* Find the longest sequence with a smaller last element (meaning a smaller
166166
* line2, as we construct the sequence with entries ordered by line1).
167167
*/
168-
static int binary_search(struct entry **sequence, int longest,
169-
struct entry *entry)
168+
static int binary_search(struct xpatience_hashmap_entry **sequence, int longest,
169+
struct xpatience_hashmap_entry *entry)
170170
{
171171
int left = -1, right = longest;
172172

@@ -191,11 +191,11 @@ static int binary_search(struct entry **sequence, int longest,
191191
* item per sequence length: the sequence with the smallest last
192192
* element (in terms of line2).
193193
*/
194-
static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
194+
static int find_longest_common_sequence(struct hashmap *map, struct xpatience_hashmap_entry **res)
195195
{
196-
struct entry **sequence;
196+
struct xpatience_hashmap_entry **sequence;
197197
int longest = 0, i;
198-
struct entry *entry;
198+
struct xpatience_hashmap_entry *entry;
199199

200200
/*
201201
* If not -1, this entry in sequence must never be overridden.
@@ -253,7 +253,7 @@ static int match(struct hashmap *map, int line1, int line2)
253253
static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
254254
int line1, int count1, int line2, int count2);
255255

256-
static int walk_common_sequence(struct hashmap *map, struct entry *first,
256+
static int walk_common_sequence(struct hashmap *map, struct xpatience_hashmap_entry *first,
257257
int line1, int count1, int line2, int count2)
258258
{
259259
int end1 = line1 + count1, end2 = line2 + count2;
@@ -324,7 +324,7 @@ static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
324324
int line1, int count1, int line2, int count2)
325325
{
326326
struct hashmap map;
327-
struct entry *first;
327+
struct xpatience_hashmap_entry *first;
328328
int result = 0;
329329

330330
/* trivial case: one side is empty */

include/git2/diff.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ typedef struct {
279279
* abbreviated to something reasonable, like 7 characters.
280280
*/
281281
uint16_t id_abbrev;
282+
283+
/// Use later GIT_EXTERN(const git_index_entry *) git_index_get_bypath(git_index *index, const char *path, int stage);
284+
/// PATCH
285+
git_time_t ctime;
286+
git_time_t mtime;
282287
} git_diff_file;
283288

284289
/**

include/git2/gitup_branch.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "common.h"
2+
#include "oid.h"
3+
#include "types.h"
4+
#include "branch.h"
5+
6+
/**
7+
* @file git2/branch.h
8+
* @brief Git branch parsing routines
9+
* @defgroup git_branch Git branch management
10+
* @ingroup Git
11+
* @{
12+
*/
13+
14+
GIT_BEGIN_DECL
15+
// PATCH
16+
// These functions are aliases and can be safely removed.
17+
// Use `git_#{func}` instead.
18+
// Replace and remove this file later.
19+
GIT_EXTERN(int) gitup_branch_upstream_name(git_buf *out, git_repository *repo, const char *refname);
20+
GIT_EXTERN(int) gitup_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname);
21+
GIT_EXTERN(int) gitup_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname);
22+
23+
/** @} */
24+
GIT_END_DECL

include/git2/gitup_clone.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include "clone.h"
2+
#include "common.h"
3+
#include "types.h"
4+
#include "indexer.h"
5+
#include "checkout.h"
6+
#include "remote.h"
7+
#include "transport.h"
8+
9+
/**
10+
* @file git2/clone.h
11+
* @brief Git cloning routines
12+
* @defgroup git_clone Git cloning routines
13+
* @ingroup Git
14+
* @{
15+
*/
16+
GIT_BEGIN_DECL
17+
18+
/**
19+
* Clone a remote repository.
20+
*
21+
* By default this creates its repository and initial remote to match
22+
* git's defaults. You can use the options in the callback to
23+
* customize how these are created.
24+
*
25+
* @param out pointer that will receive the resulting repository object
26+
* @param url the remote repository to clone
27+
* @param local_path local directory to clone to
28+
* @param options configuration options for the clone. If NULL, the
29+
* function works as though GIT_OPTIONS_INIT were passed.
30+
* @return 0 on success, any non-zero return value from a callback
31+
* function, or a negative value to indicate an error (use
32+
* `git_error_last` for a detailed error message)
33+
*/
34+
35+
/// Use `git_clone instead.
36+
GIT_EXTERN(int) gitup_clone_into(
37+
git_repository **out,
38+
const char *url,
39+
const char *local_path,
40+
const git_clone_options *options
41+
);
42+
43+
/// Deprecated
44+
/**
45+
* Clone a remote repository into an existing empty repository using
46+
* a pre-existing remote.
47+
*
48+
* @param repo the repository to clone into
49+
* @param remote the remote to use for cloning
50+
* @param fetch_opts the fetch options to use
51+
* @param checkout_opts the checkout options to use
52+
* @param branch name of the branch to checkout (NULL means use the
53+
* remote's default branch)
54+
* @return 0 on success, any non-zero return value from a callback
55+
* function, or a negative value to indicate an error
56+
*/
57+
GIT_EXTERN(int) gitup_clone_into_old(
58+
git_repository *repo,
59+
git_remote *remote,
60+
const git_fetch_options *fetch_opts,
61+
const git_checkout_options *checkout_opts,
62+
const char *branch);
63+
64+
/** @} */
65+
GIT_END_DECL

include/git2/gitup_config.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "config.h"
2+
3+
GIT_BEGIN_DECL
4+
5+
/**
6+
* Locate the path to the local configuration file
7+
*
8+
* The returned path may be used on any `git_config` call to load the local
9+
* configuration file.
10+
*
11+
* @param repo The repository whose local configuration file to find
12+
* @param out Pointer to a user-allocated git_buf in which to store the path
13+
* @return 0 if a local configuration file has been found. Its path will be stored in `out`.
14+
*/
15+
/// This function uses repository method item path.
16+
/// Maybe it is better to use `repository` method `gitup_repository_find_local_config`
17+
GIT_EXTERN(int) gitup_config_find_local(git_repository *repo, git_buf *out);
18+
19+
GIT_END_DECL

include/git2/gitup_refs.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "refs.h"
2+
3+
GIT_BEGIN_DECL
4+
5+
/**
6+
* Create a virtual direct reference.
7+
*
8+
* This is wrapper for
9+
* git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const char *log_message);
10+
*
11+
* @param out Pointer to the newly created reference
12+
* @param repo Repository where that reference virtually lives
13+
* @param name The name of the reference
14+
* @param id The object id pointed to by the reference
15+
* @return 0 on success or an error code
16+
*/
17+
GIT_EXTERN(int) gitup_reference_create_virtual(git_reference **out, git_repository *repo, const char *name, const git_oid *id);
18+
19+
/**
20+
* Create a virtual symbolic reference.
21+
*
22+
* Discussion
23+
*
24+
* This is a wrapper for
25+
* git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *log_message);
26+
*
27+
* @param out Pointer to the newly created reference
28+
* @param repo Repository where that reference virtually lives
29+
* @param name The name of the reference
30+
* @param target The target of the reference
31+
* @return 0 on success or an error code
32+
*/
33+
GIT_EXTERN(int) gitup_reference_symbolic_create_virtual(git_reference **out, git_repository *repo, const char *name, const char *target);
34+
35+
GIT_END_DECL

include/git2/gitup_repository.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "repository.h"
2+
#include "common.h"
3+
#include "types.h"
4+
#include "oid.h"
5+
#include "buffer.h"
6+
7+
/**
8+
* @file git2/gitup_repository.h
9+
* @brief Git repository management routines
10+
* @defgroup git_repository Git repository management routines
11+
* @ingroup Git
12+
* @{
13+
*/
14+
GIT_BEGIN_DECL
15+
16+
/**
17+
* Update or rewrite the gitlink in the workdir
18+
*/
19+
GIT_EXTERN(int) gitup_repository_update_gitlink(
20+
git_repository *repo, int use_relative_path);
21+
22+
/**
23+
* Locate the path to the local configuration file
24+
*
25+
* The returned path may be used on any `git_config` call to load the local
26+
* configuration file.
27+
*
28+
* @param repo The repository whose local configuration file to find
29+
* @param out Pointer to a user-allocated git_buf in which to store the path
30+
* @return 0 if a local configuration file has been found. Its path will be stored in `out`.
31+
*/
32+
GIT_EXTERN(int) gitup_repository_local_config_path(git_buf *out, git_repository *repo);
33+
34+
/** @} */
35+
GIT_END_DECL

include/git2/gitup_submodule.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "submodule.h"
2+
3+
GIT_BEGIN_DECL
4+
5+
/**
6+
* Retains a submodule
7+
*
8+
* @param submodule Submodule object
9+
*/
10+
GIT_EXTERN(void) gitup_submodule_dup(git_submodule *submodule);
11+
12+
GIT_END_DECL

include/git2/remote.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,13 @@ typedef struct {
511511
*
512512
* @param updates an array containing the updates which will be sent
513513
* as commands to the destination.
514+
* @param the remote being pushed /// PATCH
514515
* @param len number of elements in `updates`
515516
* @param payload Payload provided by the caller
516517
* @return 0 or an error code to stop the push
517518
*/
518519
typedef int GIT_CALLBACK(git_push_negotiation)(
520+
git_remote *remote,
519521
const git_push_update **updates,
520522
size_t len,
521523
void *payload);

0 commit comments

Comments
 (0)