Skip to content

Commit 400e944

Browse files
derrickstoleedscho
authored andcommitted
gvfs-helper: emit advice on transient errors
Users sometimes see transient network errors, but they are actually due to some other problem within the installation of a packfile. Observed resolutions include freeing up space on a full disk or deleting the shared object cache because something was broken due to a file corruption or power outage. This change only provides the advice to suggest those workarounds to help users help themselves. This is our first advice custom to the microsoft/git fork, so I have partitioned the key away from the others to avoid adjacent change conflicts (at least until upstream adds a new change at the end of the alphabetical list). We could consider providing a tool that does a more robust check of the shared object cache, but since 'git fsck' isn't safe to run as it may download missing objects, we do not have that ability at the moment. The good news is that it is safe to delete and rebuild the shared object cache as long as all local branches are pushed. The branches must be pushed because the local .git/objects/ directory is moved to the shared object cache in the 'cache-local-objects' maintenance task. Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent dbf92c7 commit 400e944

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

advice.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ static struct {
9393
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig" },
9494
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor" },
9595
[ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan" },
96+
97+
/* microsoft/git custom advice below: */
98+
[ADVICE_GVFS_HELPER_TRANSIENT_RETRY] = { "gvfs.transientRetry"},
9699
};
97100

98101
static const char turn_off_instructions[] =

advice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ enum advice_type {
6060
ADVICE_USE_CORE_FSMONITOR_CONFIG,
6161
ADVICE_WAITING_FOR_EDITOR,
6262
ADVICE_WORKTREE_ADD_ORPHAN,
63+
64+
/* microsoft/git custom advice below: */
65+
ADVICE_GVFS_HELPER_TRANSIENT_RETRY,
6366
};
6467

6568
int git_default_advice_config(const char *var, const char *value);

gvfs-helper.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@
255255
#include "packfile.h"
256256
#include "date.h"
257257
#include "versioncmp.h"
258+
#include "advice.h"
258259

259260
#define TR2_CAT "gvfs-helper"
260261

@@ -3016,6 +3017,32 @@ static int compute_transient_delay(int attempt)
30163017
return v;
30173018
}
30183019

3020+
static void gvfs_advice_on_retry(void)
3021+
{
3022+
static int advice_given = 0;
3023+
3024+
if (advice_given)
3025+
return;
3026+
advice_given = 1;
3027+
3028+
if (gvfs_shared_cache_pathname.len) {
3029+
advise_if_enabled(ADVICE_GVFS_HELPER_TRANSIENT_RETRY,
3030+
"These retries may hint towards issues with your disk or\n"
3031+
"shared object cache. Check to see if your disk is full.\n"
3032+
"If your disk has space, then your shared object cache\n"
3033+
"may have corrupt files. Push all local branches then\n"
3034+
"delete '%s'\n"
3035+
"and run 'git fetch' to reload the cache.",
3036+
gvfs_shared_cache_pathname.buf);
3037+
} else {
3038+
advise_if_enabled(ADVICE_GVFS_HELPER_TRANSIENT_RETRY,
3039+
"These retries may hint towards issues with your disk.\n"
3040+
"Check to see if your disk is full. Note also that you\n"
3041+
"do not have a gvfs.sharedCache config, which is not\n"
3042+
"normal. You may need to delete and reclone this repo.");
3043+
}
3044+
}
3045+
30193046
/*
30203047
* Robustly make an HTTP request. Retry if necessary to hide common
30213048
* transient network errors and/or 429 blockages.
@@ -3058,6 +3085,10 @@ static void do_req__with_robust_retry(const char *url_base,
30583085
/*fallthru*/
30593086

30603087
case GH__RETRY_MODE__TRANSIENT:
3088+
/*
3089+
* Give advice for common reasons this could happen:
3090+
*/
3091+
gvfs_advice_on_retry();
30613092
params->k_transient_delay_sec =
30623093
compute_transient_delay(params->k_attempt);
30633094
continue;

0 commit comments

Comments
 (0)